Java String question
Posted on 2004-08-15
This is about "String" and "StringBuffer" in java.
what is the difference between String str="aaa" and String str1 = new String("aaa")?
Wnen we create a String object, we are creating a string that cannot be changed. Then how the string concatenation works? When we concatenate two strings we are not only changing the content but also the size of the string. This violates the string concept of "immutable and fixed length". If the string object can increase its length, what is the use of StringBuffer over String object?