what is the main difference between string and stringbuffer?
can you explain it with program?

Answer Posted / divya

String class is used to manipulate character strings that
cannot be changed.Simply stated,objects of the String are
read only and immutable.

StringBuffer class is used to represent characters that can
be modified.

Ex:Sting str=new String("core");
str +="Java";

StringBuffer str=new StringBuffer("core");
str.append("Java");

Is This Answer Correct ?    4 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can we override private method in java?

822


Define reflection.

730


Can extern variables be initialized?

675


Explain about interrupt() method of thread class ?

857


What is compareto?

733


What are examples of modifiers?

710


What is the difference between call by reference and call by pointer?

705


Can we extend immutable class?

736


What is difference between array and arraylist in java?

669


How to store image in arraylist in java?

689


What is a method signature java?

791


Explain inheritance in java?

750


What is the purpose of the wait(), notify(), and notifyall() methods in java programming?

761


What are the advantages of exception handling?

778


What are the differences between the constructors and methods?

794