Difference between String and String Buffer?

Answers were Sorted based on User's Feedback



Difference between String and String Buffer?..

Answer / janet

1. String objects are constants and immutable where as
StringBuffer objects are not.
2.String class supports constant strings where as
StringBuffer class supports growable and modifiable strings.

Is This Answer Correct ?    13 Yes 0 No

Difference between String and String Buffer?..

Answer / 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

Difference between String and String Buffer?..

Answer / ravikiran(aptech mumbai)

string is immutable
string buffer is mutable

Is This Answer Correct ?    7 Yes 0 No

Post New Answer

More Core Java Interview Questions

How to use string tokenizer class.

0 Answers  


How a class can implement an interface?

5 Answers   SysArc,


what is the Yield() method used in threads?

4 Answers   Accenture,


what happens when a thread cannot acquire a lock on an object? : Java thread

0 Answers  


What is difference between null and void?

0 Answers  






How do I get a substring?

0 Answers  


Name two subclasses of the TextComponent class?

2 Answers  


What is singleton class example?

0 Answers  


What is clipping and repainting and what is the relation between them?

1 Answers  


5 Coding best practices you learned in java?

0 Answers  


If we allocate the memory using 'new' & de-allocated using 'free' then what will happen?

0 Answers   CDAC,


How do you change an int to a string?

0 Answers  


Categories