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 return data type?
What are the steps involved to create a bean?
What is the purpose of return statement?
What is the difference between length and length () in java?
Why is whitespace important?
What is methodological theory?
Does isempty check for null?
How to sort an array in java without using sort method?
Explain java heap space and garbage collection?
Can a source file contain more than one class declaration?
Explain the public class modifier?
What is private public protected in java?
What should I import for arraylist in java?
Explain about collection interface in java?
Explain the difference between protected and default access.