获取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 虎年五一祝福语大全简短
18 出阁宴祝福语姐姐简短