Difference between String and StringBuffer



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

Random Posts

  • Explain executeUpdate Method
  • What is Event Delegation Model
  • Different types of Session Tracking
  • How To Delete the textbox using the Javascript
  • Define business logic and business method

Post a Comment