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
can u draw class/object diagram for ATM
What are the classes in the java collection framework? : java collections
Which sorting algorithm is used by collections.sort() in java ?
What is the difference between comparable and comparator in java.util pkg?
What are the types of the main implementing classes in the map interfaces? : java collections
Should we create system software ( e.g operating system ) in java ?
What are the interfaces in java collections? : java collections
What are the uses of the set interfaces in the java collections? : java collections
who will give req's to u?. how they send req's to u? . what design documents contains?. when bugs raised on other developer code how to report to them?.(throgh mail or ........). how to retrive 100 recods from dao layer to presentation layer.using which collection?. what is sequence diagram.?.
What is deque in the java collections framework? : java collections
What is the use of hashcode in java ?
Which server-side script takes the input from JavaScript, can access the database if it needs to, and processes the data.
What are the different types of classes implemented in the set interfaces? : java collections
What is iterator in the java collections framework? : java collections
Hi frnds how to lock an user when he enter wrong credentials more than 3 time using java or j2ee tech take username and password in a bean no need to connect DB and validate give me some sample application code or links its urgent for me thanks in advance