class A implements Clonable{
Properties prop=new Properties();
public void setProperties(Properties p){
prop=p;
} protected Object clone(){
Object o=null;
try{
o=super.clone();
}
catch(CloneNotSupportedException e){
e.printStackTrace();
}
((A) o).setProperties((Properties) prop.clone());
return o;
}
}
Properties prop=new Properties();
public void setProperties(Properties p){
prop=p;
} protected Object clone(){
Object o=null;
try{
o=super.clone();
}
catch(CloneNotSupportedException e){
e.printStackTrace();
}
((A) o).setProperties((Properties) prop.clone());
return o;
}
}
就是说你的a.prop and b.prop指的是同一个地址。
我是不是应该new 一个新的?
ok,问题解决了,感谢二位,分不多了,凑合吧