获取Java整数的哈希码
整数的HashCode可以使用hashCode()Java中的方法获得。此方法不接受任何参数,它返回Integer对象的哈希码值。
hashCode()给出了演示Java方法的程序,如下所示:
示例
import java.lang.*;
public class Demo {
public static void main(String args[]) {
Integer i = new Integer(60);
System.out.println("The integer value is: " + i);
System.out.println("The Hashcode for the above value is: " + i.hashCode());
}
}输出结果
The integer value is: 60 The Hashcode for the above value is: 60
现在让我们了解上面的程序。
定义了整数i。然后,使用该hashCode()方法打印Integer值,并打印其HashCode。演示此代码段如下:
Integer i = new Integer(60);
System.out.println("The integer value is: " + i);
System.out.println("The Hashcode for the above value is: " + i.hashCode());热门推荐
10 儿子立冬祝福语简短独特
11 对当兵的祝福语简短
12 侄儿高考试祝福语简短
13 伴郎红包祝福语朋友简短
14 媳妇生日简短祝福语朋友
15 公司年会祝福语简短最好
16 元旦感恩祝福语简短大全
17 红包祝福语简短10字
18 周六早晨祝福语简短