import java.util.Arrays;
public class maopao implements Cloneable {
@Override
protected Object clone() throws CloneNotSupportedException {
// TODO Auto-generated method stub
maopao a=null;
a=(maopao)super.clone();
return a;
}
/**
* @param args
*/
String name="beautiful gril";
int id=80;
public static void main(String[] args) {
maopao a=new maopao();
a.id=90;
maopao b=null;
try {
b = (maopao) a.clone();
} catch (CloneNotSupportedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
a.name="so beautiful";
b.name="she is my girl friend";
System.out.println("a的id= "+a.id+"b的id= "+b.id);
System.out.println(a.name+"! "+b.name);
}
}

被折叠的 条评论
为什么被折叠?



