Java String is an inbuilt class that deals with all that is written in double quotation marks, or other words string is a collection of characters. For example – “Java” is a String of length 4. Every string is an instance of this class. They are immutable, and so once written, and their value cannot be changed.
See the following figure.
The string is a sequence of characters. In Java, objects of String are immutable, which means a constant and cannot be changed once created. The java.lang.String class provides a lot of functions to work on the string. With the help of these functions, we can perform the operations on string such as trimming, concatenating, converting, comparing, replacing strings, etc.
Strings are used as parameters for many Java classes e.g.
In case if strings were not immutable, this would have jeopardized the security.
#java #java string class #java.lang.string