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 the difference between comparator and comparable in java?
What are the access modifiers in java?
Can we serialize arraylist in java?
Can I uninstall java?
What do you mean by composition in java?
What happens if we override only equals?
Can inner class have constructor?
What are the main uses of java?
when you will synchronize a piece of your code? : Java thread
what is synchronization and why is it important? : Java thread
What is number data type in java?
How to store image in arraylist in java?
Why java is considered as platform independent?
I want to re-reach and use an object once it has been garbage collected. How it's possible?
When wait(), notify(), notifyall() methods are called does it releases the lock or holds the acquired lock?