Java 中的 Instant hashCode() 方法
可以使用 Java 中 Instant 类的 hashCode() 方法来获取特定 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);
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP