Difference between String & StringBuffer

Answer Posted / nilesh bhil( mca) amravati

String is immutable.
It means that we cant change the content of String once created. If we try append a new string using + operator
then it creates new String object.
ex.
string s = new String("Java");
s = s + "bean" ;// this statement creates new object.
String class does not have method that append new String to old String in object.


where as StringBuffer class is mutable. It means that we can add new String to it using append() method.
ex.
StringBuffer sb = new StringBuffer("Java");
sb.append("Bean");

Is This Answer Correct ?    38 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Q1.A. Write note on “The class path Environment Variable”? B. Which are different kinds of source code? Q2.A. How to create an interface? B. Why convert an applet to an application? Q3.A. How to use Media tracker Class. B. How to use string tokenizer class. Q4 A. Explain the overview of UDP messaging. B. Difference between SQL Exception class and SQL Warning class. Q5. A. How to create com object in Java? B. Write short notes on “The properties class” Q6. A. When object is created and destroyed? B. Explain the JDB in depth & command line. C. Write short notes on Web Sites.

7414


Explain 5 features introduced in jdk 1.7?

607


In which order the iterator iterates over collection?

579


How do you trim a space in java?

498


Difference between java and javascript

580






How can we make a class singleton?

570


What is the purpose of checked and unchecked exceptions in JAVA?

564


What about member inner classes?

624


What is hashset in java?

524


What are data types in oop?

547


What is the purpose of void?

534


Is multiple inheritance supported by java?

504


How do you do absolute value in java?

523


What are void methods?

568


What are the types of inner classes (non-static nested class) used in java?

560