Java Developers
Group for Java developers and programmers. Ask questions and get answers related to Java programming
263 Members
Join this group to post and comment.
Soubhik Maji
Soubhik Maji
Computer Science
11 Jan 2019

Java String Handling Explained

Make yourself aware about java control statement s if you aren' t  already. 

1.String is a class in java .

2.The string that you create and use is actually an object of this class .

3. Strings are immutable .

4.Bonus:String, Integer, Byte, Short, Float, Double and all other wrapper classes objects are immutable.

5.There are number of ways to create a string in java 

6.String literals :- simple what you write inside ""

7.Using another string 

8.Using new keyword 

9.Using + operator/concat() method 

10.Equals method:- It compares whether the contents of the string are same or not 

11.== operator compared two object references. Whether they refer to the same instance or not . If two different strings are created using string literals they might refer to the same instance .Whereas if you create using new keyword , it will always be different. 

12.compateto method compares two strings and returns  for example in to(s2)

-1 ->if s1 is less than s2

0 if they are same

2 if s1>s2

P.s.:- many more functions and specifics you can explore in string class