Java.util.Date.getHashcode() 方法
描述
java.util.Date.hashCode() 方法返回此 Date 对象的哈希码。
声明
以下是 java.util.Date.hashCode() 方法的声明
public int hashCode()
参数
NA
返回值
该方法返回此 Date 对象的哈希码值。
异常
NA
示例
下面的例子展示了 java.util.Date.hashCode() 方法的使用。
package com.tutorialspoint;
import java.util.*;
public class DateDemo {
public static void main(String[] args) {
// create a date
Date date = new Date(99, 5, 10);
// display current date
System.out.println("The current date shows: " + date.toString());
// get the hash code and print it
int i = date.hashCode();
System.out.println("A hash code for this date is: " + i);
}
}
让我们编译并运行上面的程序,这将产生以下结果 −
The current date shows: Thu Jun 10 00:00:00 EEST 1999 A hash code for this calendar is: 1249064024

