Strings - Introduction

Introduction: -


Strings are called character array. i.e. 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 most important topic from 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 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 inbult methods like touppercase, tolowercase .. etc.



 in the next post i will tell you how to convert from int to string and vice versa.



Comments

Related Posts Plugin for WordPress, Blogger...