获取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());热门推荐
1 如何训练狗狗不叫
2 训练狗狗不叫
3 训练狗狗随行
4 怎么训练狗狗不叫
7 训练比熊狗狗教程
10 上海狗狗训练
11 怎么训练狗狗上厕所
12 训练狗狗趴下
13 狗狗服从训练
14 训练狗狗拒食
15 训练狗狗笑
16 训练狗狗大便
17 训练狗狗立
18 训练狗狗捡东西