Difference between String and String Buffer?

Answer Posted / sumati

String is immutable
String buffer is mutable

Ex String str = "abc";
str = "new String";
this will creat new memory location and stores "new String"

but in String buffer
StringBuffer strBuf = "abc";
strBuf = "new String"

it will overwrite in same memory location

Is This Answer Correct ?    13 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are heterogeneous objects?

662


What is set and get methods in java?

632


What does flag mean in java?

619


What does sizeof return?

638


What is overloading and overriding in java?

765






What data type is true or false?

670


What are variable arguments or varargs?

670


Is null == null in java?

748


Which class cannot be a subclass in java?

625


design an lru cache in java?

634


Explain the concept of hashtables?

713


String class is defined under which package in java?

704


What are the legal operands of the instanceof operator?

661


What are the major drawbacks of external iteration?

668


What is JFC?

802