java.lang.Character.Subset.hashCode()方法實例
java.lang.Character.Subset.hashCode() 方法返回標準的散列碼。
聲明
以下是java.lang.Character.Subset.hashCode()方法的聲明
public final int hashCode()
參數
-
NA
返回值
此方法返回該對象的哈希碼值。
異常
-
NA
例子
下麵的例子顯示java.lang.Character.Subset.hashCode()方法的使用。
package com.yiibai; import java.lang.*; public class CharacterSubsetDemo extends Character.Subset { // constructor of super class CharacterSubsetDemo(String s) { super(s); } public static void main(String[] args) { CharacterSubsetDemo obj1 = new CharacterSubsetDemo("admin"); CharacterSubsetDemo obj2 = new CharacterSubsetDemo("webmaster"); CharacterSubsetDemo obj3 = new CharacterSubsetDemo("administrator"); // returns a hash code value int retval = obj1.hashCode(); System.out.println("Hash code of Object " + obj1 + " = " + retval); retval = obj2.hashCode(); System.out.println("Hash code of Object " + obj2 + " = " + retval); retval = obj3.hashCode(); System.out.println("Hash code of Object " + obj3 + " = " + retval); } }
讓我們來編譯和運行上麵的程序,這將產生以下結果:
Hash code of Object admin = 1414159026 Hash code of Object webmaster = 1569228633 Hash code of Object administrator = 778966024