Difference between String and StringBuffer.

Answers were Sorted based on User's Feedback



Difference between String and StringBuffer...

Answer / minu

hi
i am agree with Madhu ,
String is an immutable object. StringBuffer is a mutable
object.
immutable object:If you are not allowed to change the value
of an object, it is immutable object.

mutable object: If a object value is changeable then we can
call it as Mutable object.

Is This Answer Correct ?    14 Yes 0 No

Difference between String and StringBuffer...

Answer / madhu

string is imutable and stringbuffer is mutable

Mutable means storing location is same
Imutable means storning location is different

Is This Answer Correct ?    8 Yes 0 No

Difference between String and StringBuffer...

Answer / geetha

String and StringBuilder class stores strings. But when you
cannot change a String object after creating one.
eg: String name = "Prasad";
By saying you cannot change the name object means you cannot
change the value in name object internally. When you change
the name object value to something else, a new String object
is creating in memory and assign the new value.

eg: name = "Prasad Reddy";

A new name object is creating in memory and the value
"Prasad Reddy" is assinging to the newly created space.

But StringBuilder class occupies the same space even if you
change the value.

If you are doing string concatenation StringBuilder class is
far better in performance than String class.

You can use StringBuilder's Append() method to use
concatenation.

Is This Answer Correct ?    5 Yes 0 No

Post New Answer

More Core Java Interview Questions

Can a class be final?

0 Answers  


Is ruby built on java?

0 Answers  


Why strings in java are called as immutable?

0 Answers  


How to synchonise HashMap

4 Answers   IBM,


What is :: operator in java 8?

0 Answers  






Given a singly linked list, determine whether it contains a loop or not without using temporary space?

0 Answers   Global Logic,


What is method and methodology?

0 Answers  


can we take more than one null values for Unique constraints.

1 Answers   3i Infotech,


Need 2+ yrs experienced java techinical question papaer for company Iflex

1 Answers   TCS,


Does java support multi dimensional arrays ?

6 Answers  


What is the life cycle of an Applet ?

1 Answers  


What is run-time class and system class? what is their purpose?

1 Answers  


Categories