Category Archives: Java String

Java StringBuffer Class

In this tutorial you will learn about Java StringBuffer class and its important methods with examples. StringBuffer in Java is used to create mutable strings. Here mutable means, we can modify or change the strings. StringBuffer class is thread safe which means multiple threads can’t access the same object simultaneously. Apart from StringBuffer, we can… Read More »

Difference Between equals() and == in Java

The equals() method and == operator in Java perform two different operations. The equals() method is used to compare two string values. On the other hand == operator is used to compare two primitive datatype variables or to compare references of two objects. Below is a sample program that shows difference between equals() and ==… Read More »

Java String Comparison

String class in Java provides different methods for comparing strings or substrings within strings. In this tutorial I will discuss about those Java string comparison methods.   equals() and equalsIgnoreCase() We can use equals() method to check equality of two strings. It has following syntax. Syntax

  Here str is the String object and… Read More »

Character Extraction in Java

There are several ways by which characters can be extracted from String class object. String is treated as an object in Java so we can’t directly access the characters that comprise a string. For doing this String class provides various predefined methods.   Character Extraction in Java charAt() charAt() method is used to extract a… Read More »

How to Check String is Alphanumeric in Java

You can check string is alphanumeric in Java using matches() method of Matcher class. The Matcher class is provided by java.util.regex package. Below I have shared a simple Java program in which I have taken a string and I am checking it using matches() method.   Java Program to Check String is Alphanumeric or not

Read More »

String in Java

String in Java is a sequence of characters. In other programming languages like C and C++, string is implemented as array of characters while in Java string is implemented as object of String class. String class is defined in java.lang package. StringBuffer and StringBuilder class is also used to create string in Java. We will… Read More »

Program for String Concatenation in Java

Concatenation is the process of combining two or more small strings to from a bigger string. String concatenation in java can be done in four different ways given below. 1. Using + operator 2. Using concat() method of String class 3. Using append() method of StringBuffer class 4. Using append() method of StringBuilder class In… Read More »