Difference between String and StringBuffer
By Ramakrishna on Aug 24, 2008 in String Class
Q) what is the difference between String and StringBuffer?
A)
–>String class objects are Immutable.
–>StringBuffer objects are mutable.
Why String objects are Immutable:
Click this JVM to know the defination(other def) takes less time to create a new String object than to Re allocate memory to the existing object and modify its contents it will take more memory so it will create a new object.
Mutable Objects : The objects whose data can be modified are called mutable objects.
once we use the value we can modify it is called mutable.
Immutable objects : Immutable objects are those objects whose contents can’t be modified
once you create an Input and Output we can’t change the content object
String class objects are Immutable.
String Class does’t contain methods which directory manipulate the object contents but StringBuffer class has such methods
