Strings – Introduction

Introduction: –

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”;
Example:
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.
0 0 vote
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x