Series: Subject: Topic:
Question: 240 of 577

what is the difference between String and StringBuffer?

Asked by: ramesh_etta | Member Since Nov-2006 | Asked on: Nov 10th, 2006

View all questions by ramesh_etta

Showing Answers 1 - 11 of 11 Answers

 The methods in string class are not sychronized.Where as the methods of the StringBuffer class can be synchronized .

Login to rate this answer.
Srikanth Rao

Answered On : Nov 13th, 2006

1.String Class is inMutable, and StringBuffer is Mutable2.String Class Don't have append Method

Yes  1 User has rated as useful.
Login to rate this answer.

Answered On : Nov 16th, 2006

1)string and string buffer both implements charecter sequence interface,but strings r immutable and string buffers r mutable2)string buffers works fast for concatenation operations bcz it has append method init

Login to rate this answer.
rajendra babu

Answered On : Nov 17th, 2006

The main diff. b/w string and stringbuffer is string is immutable(cannot change the content)stringbuffer is mutable(can change the content)

Login to rate this answer.

Answered On : Nov 18th, 2006

Strings and string buffer classes are final classes in java.string buffer s have some data manipulation methods are available .in strings are not.string buffer is faster than the string.string s are immutable objects (contents of the objects cant be modified)string buffere s are mutable objects(contents of the objects can be modifies).bbye cheerschinnu

Login to rate this answer.

Answered On : Nov 23rd, 2006

String                                           StringBuffernot sychronized                     SynchronizedImmutable                             mutable

Login to rate this answer.

Answered On : Nov 29th, 2006

String StringBuffer1) String is immutable. 1)StringBuffer is muatable.2)String is Synchronised

Login to rate this answer.

String is an class and its objects are constt.String Buffer is anotehr class and is  better than string  since it saves time and memory. String buffer includes all functions of string class ,also it has one more fn,i.e sb.reverse();String objects are constt ,what it means is that the CONTENTS OF String instance cannot b changed after it has been created.This is not with StringBuffer instance.bye

Login to rate this answer.

Answered On : Jan 11th, 2007

1.String is immutable               --  StringBuffer is not.2. String is not threadsafe        -- StringBuffer is thread safe3. String has concat() for append character   -- StringBuffer has append() method4. while you create String like, String str = new String(); --> it create 2 object 1 on heap and 1 on "String Constant pool" and that refered by str               --- That's not in StringBuffer , it Create 1 object on heap5. String is most commanly use in java applications     ---- Mostly used in I/O functions.-----------------------------------------------------------------------------------------------------------As for Java 5 new class was added -- StringBuilder , that has same functionlity as StringBuffer but it is not thread safe.-----------------------------------------------------------------------------------------------------------Simmilarity is that .... Both are final class

Login to rate this answer.

Answered On : Oct 12th, 2007

Strings are immutable that means we cann't change the content or data. Where in the case of StringBuffer we can change the data or content that are presented in that.

Login to rate this answer.

Answered On : Feb 22nd, 2008

View all answers by sampra

One majar diff also is string obj are immutable where as string buffer objects are mutable  

Login to rate this answer.

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

Related Open Questions



twitter fb Linkedin GPlus RSS


Interview Question

 Ask Interview Question?


Latest Questions

Interview & Career Tips

Get invaluable Interview and Career Tips delivered directly to your inbox. Get your news alert set up today, Once you confirm your Email subscription, you will be able to download Job Inteview Questions Ebook . Please contact me if you there is any issue with the download.