If not override equals(), for any reference values x and y, this method returns true if and only if x and y refer to the same object (x==y has the value true). Integer overrided equals() method, while Value didn't. So you have different results.

解决方案 »

  1.   

    因为默认的equals是object对象的equals,只要没有override这个方法的变量都是默认比较的对象引用。
      

  2.   

    缺省情况下equals是比较对象的地址的,因为Object类的equals就是比较地址的,如果你复写了equals方法,那么就可以按照自己定义原则来进行比较,也就是按内容比较。
    你的Value类缺省继承Object,所以equals比较对象地址,而Integer类复写了equals方法,它是按照包装在里面的int数值进行比较的。