Java ChronoLocalDate hashCode()方法及示例
Java中 ChronoLocalDate接口 的 hashCode() 方法是用来获取ChronoLocalDate对象的整数形式的hashCode值。
语法:
public int hashCode()
参数 :该方法不接受任何参数。
返回值 :该函数以整数形式返回一个合适的哈希代码。
以下程序说明了Java中ChronoLocalDate的 hashCode() 方法。
程序1 :
// Program to illustrate the hashCode() method import java.util.*;import java.time.*;import java.time.chrono.*; public class GfG { public static void main(String[] args) { // Parses the date ChronoLocalDate dt = LocalDate.parse("2018-11-27"); // Prints the hash-code System.out.println(dt.hashCode()); }}
输出。
4133595
程序2 :
// Program to illustrate the hashCode() method import java.util.*;import java.time.*;import java.time.chrono.*; public class GfG { public static void main(String[] args) { // Parses the date ChronoLocalDate dt = LocalDate.parse("2015-12-23"); // Prints the hash-code System.out.println(dt.hashCode()); }}输出。
4127511
参考资料 : https://docs.oracle.com/javase/9/docs/api/java/time/chrono/ChronoLocalDate.html#hashCode-
