Java 8 Clock hashCode() 方法
可以利用 Java 中 Clock 类的 hashCode() 方法来获取时钟对象哈希码。此方法不需要参数,它将返回一个时钟对象的有效哈希码。
演示这一点的示例如下 −
示例
import java.time.*;
public class Demo {
public static void main(String[] args) {
Clock c = Clock.systemDefaultZone();
int hashCode = c.hashCode();
System.out.println("The clock is: " + c);
System.out.println("The hash code is: " + hashCode);
}
}输出
The clock is: SystemClock[Etc/UTC] The hash code is: 227139178
现在让我们来理解以上程序。
可以使用 hashCode() 方法来获取指定时钟对象的哈希码,然后显示此值。演示这一点的代码段如下 −
Clock c = Clock.systemDefaultZone();
int hashCode = c.hashCode();
System.out.println("The clock is: " + c);
System.out.println("The hash code is: " + hashCode);
广告
数据结构
网络
关系型数据库管理系统
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
JavaScript
PHP