Strings are called character array. i.e. sequence of characters.
This is a class that is defined in java.lang package.
Always Remember it is not a data type.
This is one of the most important topics from which questions are asked in interviews.
Declaration of Strings: –
String string_name = “put your content inside double quotes”;
String s = “Ravi”;
If you will use char then use a single quote and for string use double-quotes.
String class has many inbuilt methods. Let’s explore them –
How to find the length of String?
The string class has a length() method for this.
String s = “Ravi”; s.length(); // it will return the length of string.
How to change cases of String?
They have inbuilt methods like touppercase, tolowercase .. etc.
in the next post, I will tell you how to convert from int to string and vice versa.