what is diff string and stringbuffer

Answer Posted / sudheer babu

Both string and string buffer are different ,in the case of
the String it can ready only and immutable where as the
String Buffer is the modifier and mutable.
EX:
String s1="abc";
S.o.p(s1);---------->o/p is abc
StringBuffer sb=new StringBuffer("abc");
s.o.p(sb);---------->o/p is abc
here we can modify the String buffer values if we want i.e
sb.append("z");
s.o.p(sb);----------->0/p is abcz

"this is the basic difference between the String and String
Buffer."

Is This Answer Correct ?    8 Yes 9 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the use of the list interface in the java collection? : java collections

592


What are the types of the main implementing classes in the map interfaces? : java collections

600


can u draw class/object diagram for ATM

5523


Which server-side script takes the input from JavaScript, can access the database if it needs to, and processes the data.

1588


What are the queues in the java collection framework? : java collections

537






What are the uses of the set interfaces in the java collections? : java collections

528


Hi we have an urgent requirement for Java/J2ee technical lead position & also looking for "Java Guidewire claimcentre" experienced professional for Bangalore location if interested can reach srisanh@gmail.com

2528


What is java collection? : java collections

564


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

1859


What is the use of hashcode in java ?

566


What is deque in the java collections framework? : java collections

533


What are maps interfaces in the java collections? : java collections

563


What do you understand by synchronization? Why is it important?

557


How is hashset maintained in memory by java ?

583


Which sorting algorithm is used by collections.sort() in java ?

541