<pre name="code" class="java">OOP练习
public static void main(String[] args) throws CloneNotSupportedException {
StringBuffer sb = new StringBuffer("abc");
StringBuffer sb2 = sb;
sb.append("ABC");
System.out.println("sb = " + sb);
System.out.println("sb2 = " + sb2); //sb2值改变,和sb引用桶一个变量
String str = "abc";
String str2 = str;
str += "123";
System.out.println("str = "+str);
System.out.println("str2 = "+str2); //不改变
int i = 1;
int ii = i;
i++;
System.out.println("i = "+ i);
System.out.println("ii = "+ ii); //不改变
CloneDemo cd = new CloneDemo();
cd.name = "CloneDemoFather";
CloneDemo cd2 = cd.clone();
System.out.println(cd2.name);
}