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;
  }
}

解决方案 »

  1.   

    that's so-called Deep Clone
      

  2.   

    Maybe you need more codes to deal with Properties.clone(), I think it's a shallow clone.
      

  3.   

    对呀,你的prop也是非原始的数据类型,同样需要进一步的克隆!
    就是说你的a.prop and b.prop指的是同一个地址。
      

  4.   

    那如果我还有一个String类型的属性呢,它好像不能clone
    我是不是应该new 一个新的?
      

  5.   

    可以了,只不过你要把new完的实例赋相同的值,为什么不用clone?
      

  6.   

    好像final的类不能clone
    ok,问题解决了,感谢二位,分不多了,凑合吧