不会吧?这种情况hashCode怎么可能一样?

解决方案 »

  1.   

         *     It is <em>not</em> required that if two objects are unequal 
         *     according to the {@link java.lang.Object#equals(java.lang.Object)} 
         *     method, then calling the <tt>hashCode</tt> method on each of the 
         *     two objects must produce distinct integer results.  However, the 
         *     programmer should be aware that producing distinct integer results 
         *     for unequal objects may improve the performance of hashtables.你一定没有读完jdk注释的全文,前面还加了重点符号来说"not" required 。后面也用"However"特别强调了注意事项。
      

  2.   

    hashCode 也不保证一定不同
      

  3.   

    这种可能性也不是没有啊。hashcode本来就是有可能一样的啊。
      

  4.   

    这种情况很正常,equals返回结果为false,没有要求hashCode也一定相等。源码注释说明的很明确了。