Java 中 Duration hashCode() 方法
可以使用 Java 中 Duration 類的 hashCode() 方法獲取持續時間的雜湊碼值。此方法不需要引數,它會返回持續時間的雜湊碼值。
演示此方法的程式如下 −
示例
import java.time.Duration;
public class Demo {
public static void main(String[] args) {
Duration d = Duration.ofDays(2);
System.out.println("The duration is: " + d);
System.out.println("The hash code of the duration is: " + d.hashCode());
}
}輸出
The duration is: PT48H The hash code of the duration is: 172800
現在我們來理解一下上述程式。
顯示持續時間,然後使用 hashCode() 方法獲取持續時間的雜湊碼值並顯示。演示此方法的程式碼片段如下 −
Duration d = Duration.ofDays(2);
System.out.println("The duration is: " + d);
System.out.println("The hash code of the duration is: " + d.hashCode());
廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP