RE: What is the difference between String and StringBu...
String buffer is a mutable string object. String is a non - mutable object. When we say mutable means which can be changed anytime. Its better to string buffer if we want to modify a string from multiple threads(Some places synchronization is required).
RE: What is the difference between String and StringBu...
String buffer is a mutable string object. String is a non - mutable object. When we say mutable means which can be changed anytime. Its better to string buffer if we want to modify a string from multiple threads(Some places synchronization is required).
RE: What is the difference between String and StringBu...
When a String is created it is not destroyed. It remains in the pool of memory and whenever that string is referred the JVM searches for the String from the string pool of memory and gets the relevant data. So as such String is expensive operation.
String buffer can be changed/modified based on our requirement. There are chances that you may need to form a query based on some conditions. Such queries can be formed using String buffer. Finally you can user the toString method to get the final String version of the stringBuffer.
Pls mail back if you are unclear with any of the items that I have specified in this solution.
RE: What is the difference between String and StringBu...
String class objects are immutable(not change).StringBuffer class objects are mutable(change).In our project for constants use String class object for variables use StringBuffer class object then performance will be increased.