I have a question about the length() method. Please read the code below.
public class BuffString{
public static void main(
String args[]){
StringBuffer s1 = new StringBuffer("12345");
StringBuffer s2 = new StringBuffer("abcde");
StringBuffer s3 = s1.append(s2);
System.out.println(s1);
}
}
//output
12345abcde
I don't understand why s1 should contain the addition of s1 and s2? Is it impossible to keep the original value for s1? Why can't we have three different StringBuffers with differrent values? Why is the rule this way?
Please someone explain about this so I shut up and stop whining.