Re: [問題] 物件參照印出來的東西
※ 引述《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
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 3 之 3 篇):