A String is a class in Java and it can be seen as a collection or a sequence of characters. Strings are used as an object in Java. Java supports different methods for String Manipulation. In the next section, we will cover all the important string methods along with a brief description of each of them.
Java String class is an immutable class i.e. once it is created, it can’t be modified after that. This is the reason why StringBuffer and StringBuilder came into the picture as they are mutable and are used to do a lot of modification to the sequence of characters even after creation.
char ch1 = 'a';
char ch2 = ' ';
char ch3 = '1';
It means that a String is always enclosed within double quotes. Whenever we want to perform any task either with the characters or with the set of
characters (String), Java language provides relevant functions (i.e. character function and String function) to perform the desired tasks. Some of the important functions are explained below.
String str1 = "Hello world";
String str2 = "";
String str3 = "12345";
String str4 = "This is a "quote" in a string";
characters (String), Java language provides relevant functions (i.e. character function and String function) to perform the desired tasks. Some of the important functions are explained below.