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);热门推荐
5 薛之谦祝福语简短
10 水晶婚夫妻祝福语简短
11 牛年佛家祝福语大全简短
12 老师新婚快乐祝福语简短
13 送给同桌的祝福语简短
14 甄嬛传祝福语简短
15 恭喜新郎父母简短祝福语
16 中班入学祝福语简短大全
17 白羊生日祝福语 简短独特
18 韩语贺卡祝福语简短版