方法 | 描述 |
---|---|
static int identityHashCode(Object x) | 取得物件的雜湊碼 |
舉例如下
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | class HashDemo { public static void main(String[] args) { String s1 = "" ; String s2 = "12345" ; String s3 = "hello" ; String s4 = "" ; String s5 = "12345" ; String s6 = "hello" ; System.out.println(System.identityHashCode(s1)); System.out.println(System.identityHashCode(s2)); System.out.println(System.identityHashCode(s3)); System.out.println(System.identityHashCode(s4)); System.out.println(System.identityHashCode(s5)); System.out.println(System.identityHashCode(s6)); } } /* 《程式語言教學誌》的範例程式 檔名:HashDemo.java 功能:示範物件導向的基本觀念 作者:張凱慶 時間:西元 2010 年 10 月 */ |
編譯後執行,結果如下

中英文術語對照 | |
---|---|
類別 | class |
方法 | method |
物件 | object |
沒有留言:
張貼留言