java.lang.Integer.hashCode()%uA0方法返回这个Integer的哈希码。
声明
以下是java.lang.Integer.hashCode()方法的声明
public int hashCode()
参数
-
NA
返回值
该方法返回这个对象一个哈希码值,等于这个Integer对象表示的int值。
异常
-
NA
例子
下面的例子显示java.lang.Integer.hashCode()方法的使用。
package com.yiibai import java.lang.* public class IntegerDemo { public static void main(String[] args) { Integer i = new Integer("20") /* returns a hash code value for this object, equal to the primitive int value represented by this Integer object */ int retval = i.hashCode() System.out.println("Value = " + retval) } }
让我们来编译和运行上面的程序,这将产生以下结果:
Value = 20