·
String class is used to handle the String value
in the program. This class is available in “package java.lang.String”
·
String class is final class, it can be inherited
to any subclass
·
We can create object of String class in 2 ways:
(1)
Using new operands
(2)
Using double quotes
NOTE: From
jdk 1.5 onwards, 2 additional classes are introduced to create String object.
(1) String Builder
(2) String Buffer
Both cases are Mutable
Classes means object value can be changed. Using these 2 classes we can
create String object by using new operand only.
·
For these 2 classes reverse method is also
available.
NOTE: String
class designs Immutable Classes.
Once string object is created its value cannot be changed. If the object values
are getting changed then it will create new object instead of pointing existing
one.
·
When the objects are created using new operands,
then new object is created in the memory even though object is already existing
“It allows Duplicate objects”
·
When String object is created by enclosing in
double quotes, it creates new object only if the object is unique. Otherwise it
reuses the existing object
·
The uniqueness of an object is identified based
on the String value
·
String class is Immutable class. Once String object is created, its value cannot be
changed
·
If the object values are changed, the it creates
new object instead of changing existing one
·
In String class toString() is overrided to
return the value of object
NOTE: From
jdk 1.5 onwards, 2 additional classes are introduced to create String object
(1)
String Builder
(2)
String Buffer
Both classes are mutable
classes, means that the object value can be changed. In these classes we
can create String object by using new operand only
NOTE: For
these 2 classes 1 additional method is also available by name reverse
No comments:
Post a Comment