java中Integer中的hashCode方法
java中Integer中的hashCode方法,是重写的,下面抄了部分Integer类的实现public String toString() {return String.valueOf(value);}/*** Returns a hash code for this Integer.** @returna hash
·
java中Integer中的hashCode方法,是重写的,下面抄了部分Integer类的实现
public String toString() {
return String.valueOf(value);
}
/**
* Returns a hash code for this <code>Integer</code>.
*
* @return a hash code value for this object, equal to the
* primitive <code>int</code> value represented by this
* <code>Integer</code> object.
*/
public int hashCode() {
return value;
}
我们可以看到,实际上,Integer就是很简单的重写了一下toString和hashCode方法,就是返回本身的值。
魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。
更多推荐


所有评论(0)