码迷,mamicode.com
首页 > 其他好文 > 详细

有关哈希码的东西

时间:2014-12-07 19:08:26      阅读:155      评论:0      收藏:0      [点我收藏+]

标签:style   ar   color   os   sp   java   on   div   as   

1.在Java中,哈希码代表对象的特征。

例如对象 String str1 = “aa”, str1.hashCode= 3104
String str2 = “bb”, str2.hashCode= 3106
String str3 = “aa”, str3.hashCode= 3104
根据HashCode由此可得出str1!=str2,str1==str3
2.
==比较两个变量本身的值,即两个对象在内存中的首地址。
equals方法对于字符串来说是比较内容的,而对于非字符串来说是比较

其指向的对象是否相同的。

有关哈希码的东西

标签:style   ar   color   os   sp   java   on   div   as   

原文地址:http://www.cnblogs.com/lgaigai/p/4149670.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!