Introduction: –

Strings are called character array. i.e. a sequence of characters.

This is a class which is defined in java.lang package.

 Always Remember it is not a data type.

This is one of the most important topics of which questions are asked in interviews.

Declaration of Strings: –

String string_name = “put your content inside double quotes”;

Example:

String s = “Ravi”;

 

Note:

If you will use char then use 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?

String class has 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.

 

LEAVE A REPLY

Please enter your comment!
Please enter your name here