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
Explain how to force the garbage collection in java.
Why singleton class is used in java?
What is command line argument
What kind of variables can a class consist?
Explain the available thread states in a high-level?
How do you remove all elements from an arraylist in java?
How will you initialize an Applet?
Define array. Tell me about 2-D array.
What does main method?
If try block is successfully executed, Then Is Finally block executed?
What is a variable in java?
What are data structures in java?
What does the exclamation mark mean in java?
What is flush buffer?
What is the advantage of functional interface in java 8?