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