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);热门推荐
4 圆圆的祝福语简短
9 送蛇的祝福语简短
10 祝福语诗意文案简短
11 Q穷人结婚祝福语简短
12 国庆中秋祝福语简短搞笑
13 早晨好正能量祝福语简短
14 低调祝福语简短10字
15 新年祝福语简短给孩子
16 分手新年祝福语大全简短
17 18岁简短祝福语经典
18 理科元旦祝福语大全简短