public class T2 {
public static void change (String s) {
s = "hah";
System.out.println("s = "+s);
}
public static void change1 (StringBuffer sbr) {
sbr.replace(0, sbr.length(), "kk");
}
public final static void main(String[] args) {
String str = "jkl";
change(str);
System.out.println(str);
StringBuffer srb = new StringBuffer("hh");
change1(srb);
System.out.println("srb = "+srb);
}
}
operation result:
String type is immutable, the modification is invalid, the StringBuffer is a variable type, it is effective to modify