Answer Posted / monika
string is immutable, that is it can not be extended.whereas
StringBuffer is mutable and can be extended.
Fro example :
Consider 2 statement : "Welcome " and "to Java World".
now assign first statement to string and string buffer.
String str = "Welcome" & StringBuffer strBuff = new
StringBuffer("Welcome");
Now if we add 2nd statement to both then :
str= str + "to Java World" -> In this case, it would dump
all the memory allocated with "welcome" and allocate a new
memory space to the entire string "Welcome to Java World" .
On the other hand, in strBuff :-
strBuff.append("to Java World") -> if simply allocate a
new memory space to only 2nd statement and add to link to
previous name.
| Is This Answer Correct ? | 51 Yes | 7 No |
Post New Answer View All Answers
What are the different types of collections views being provided by the map interface? : java collections
What are the types of the main implementing classes in the map interfaces? : java collections
Which sorting algorithm is used by collections.sort() in java ?
What do you understand by synchronization? Why is it important?
What are the types of java collections? : java collections
What are the differences between the java collection and the java list? : java collections
In hyderabad, which s/w training center is best for java, other than corejava what r the new tools to learn in java,which tool is best & have current requirement,pls give me information about java to learn ?
What is java collection? : java collections
What is the use of hashcode in java ?
HOW MUCH PERCENTAGE WE DEDUCT FOR OUR SUPPLIERS OR OTHER PROFESSIONALS
What are maps interfaces in the java collections? : java collections
What are the uses of the set interfaces in the java collections? : java collections
What is the enumerator of the java collection framework? : java collections
Hi Friends, i have searched in google but not clear. can you give bank example with synchronized keyword
How do I find jre path in windows?