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
What is the use of inner class?
What best practices should you follow while writing multithreaded code in java?
What is classname class in java?
Why is it called buffering?
What is data and its types?
How transient variable is different from volatile variable?
What is a default constraint?
What is a nested structure?
Can extern variables be initialized?
Why is stringbuffer not immutable?
How is tree Mirroring implemented?
What is a singleton class? Give a practical example of its usage.
What are disadvantages of java?
Can we use this () and super () in a method?
How do you use parseint in java?