作者adrianshum (Alien)
看板java
标题Re: [问题] 物件参照印出来的东西
时间Mon Oct 3 23:39:52 2011
※ 引述《darkk6 (Mr. Pan)》之铭言:
: ※ 引述《aoksc (重出江湖)》之铭言:
: : 请问一下
: : 像这样
: : xxx x=new xxx();
: : println(x);
: : 如果物件的参照印出像是xxx@c17164
: : xxx表示类别
: : c17164可以算是记忆体位址吗?
: : 还只是个代表编号?
: 请参考 Object.toString()
: http://www.docjar.com/docs/api/java/lang/Object.html#toString
: public String toString()
: {
: return getClass().getName() + "@" + Integer.toHexString(hashCode());
: }
我想要加上 hashCode 的部份才完整:
http://www.docjar.com/docs/api/java/lang/Object.html#hashCode
s much as is reasonably practical, the hashCode method defined by
class {@code Object} does return distinct integers for distinct
objects. (This is typically implemented by converting the internal
address of the object into an integer, but this implementation
technique is not required by the Java programming language.)
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 183.179.61.91