Java Character.SubSet hashCode()方法

java.lang.Character.SubSet.hashCode() 方法返回标准的散列码。

1 语法

public final int hashCode()

2 参数

3 返回值

此方法返回该对象的哈希码值。

4 示例 

package com.yiidian;

/**
 * 一点教程网: http://www.yiidian.com
 */
/**
 * Java Character.SubSet hashCode()方法
 */
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

 

热门文章

优秀文章