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);热门推荐
10 对患者生日祝福语简短
11 结婚祝福语简短装备
12 周岁祝福语学生文案简短
13 订婚领证祝福语简短精辟
14 导师获奖祝福语大全简短
15 新婚购房祝福语简短精辟
16 牛年祝福语简短的爱人
17 送芒果的祝福语简短
18 送给学长毕业祝福语简短