67,513
社区成员
发帖
与我相关
我的任务
分享
public class Demo1 implements Cloneable{
public static void main(String[] args) throws Exception {
Demo1 d1 = new Demo1();
Demo1 d2 = (Demo1)d1.clone();
String c1 = "h";
String c2 = "h";
System.out.println("d1.hashCode()="+d1.hashCode()+" d2.hashCode()="+d2.hashCode());
System.out.println("d1.equals(d2) "+d1.equals(d2));
System.out.println("d1==d2 "+(d1==d2));
System.out .println();
System.out.println("c1.hashCode()="+c1.hashCode()+" c2.hashCode()="+c2.hashCode());
System.out.println("c1.equals(c2) "+c1.equals(c2));
System.out.println("c1==c2 "+(c1==c2));
}
}