获取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 带狗狗训练
4 听力训练狗狗
6 怎训练狗狗
7 腹肌训练狗狗
8 网球训练狗狗
9 记叙文训练狗狗
10 狗狗太凶怎么训练
11 核心力量训练狗狗
12 狗狗乱叫怎么训练
13 发音训练狗狗
14 怎么训练狗狗叼东西给主人
15 荆州训练狗狗
16 篮球训练狗狗
17 做训练狗狗
18 训练狗狗坐姿