=号到底比较的是什么??
先看个程序
package com.test.one;public class one {private String name;private int id;@Overridepublic int hashCode(){System.out.println("#");return 1;}//重写hashcode/.....public boolean equals(one o){if(o.name.equals(name)&&o.id==id){return true;}return true;}public static void main(String[]args){one o1=new one();one o2=new one();o1.id=1;o2.id=2;o1.name="o1";o2.name="o2";System.out.println(o1==o2);System.out.println(o1.toString());System.out.println(o1.equals(o2));}}
false#com.test.one.one@1true