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

Explain the OOPS concept in Realtime Scenarion ? Take example as CAR. Please explain indetail ?

2764


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

737


What is the Spring2.5 MVC Navigation flow?

5735


What are the different types of classes implemented in the set interfaces? : java collections

825


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

769


What are the different types of features of the java collections framework? : java collections

810


Which java collection class can be used to maintain the entries in the order in which they were last accessed?

764


How is hashset maintained in memory by java ?

833


What are the types of java collections? : java collections

728


What is an algorithm in java collection framework? : java collections

798


What is the difference between comparable and comparator in java.util pkg?

809


Which interface does java.util.hashtable implement?

910


What are the types of interface used in the java collections? : java collections

784


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

783


please mail me the interview question based on java/j2ee

1718