Java中的即时hashCode()方法
可以使用hashCode()Java中Instant类中的方法来获取特定Instant对象的哈希码。此方法不需要任何参数,它返回Instant对象的哈希码。
演示此程序如下
示例
import java.time.*;
import java.time.temporal.ChronoUnit;
public class Demo {
public static void main(String[] args) {
Instant i = Instant.now();
System.out.println("The current instant is: " + i);
int hashCode = i.hashCode();
System.out.println("The Hash Code value for the instant is: " + hashCode);
}
}输出结果
The current instant is: 2019-02-13T12:05:21.488Z The Hash Code value for the instant is: 668255745
现在让我们了解上面的程序。
首先显示当前时刻。然后,使用该hashCode()方法获取该Instant的哈希码,并显示该哈希码。演示此代码段如下所示:
Instant i = Instant.now();
System.out.println("The current instant is: " + i);
int hashCode = i.hashCode();
System.out.println("The Hash Code value for the instant is: " + hashCode);热门推荐
6 保研的祝福语简短
10 年轻20岁祝福语简短
11 朋友结婚祝福语信息简短
12 女孩婚礼贺卡祝福语简短
13 30段点歌简短祝福语
14 虎年春节祝福语图文简短
15 写给后妈祝福语大全简短
16 简短回复生日祝福语
17 校长送毕业祝福语简短
18 毕业立体贺卡祝福语简短