java.util.Date.hashCode() 方法返回此对象的哈希代码值。
语法
public int hashCode()
参数
无需参数。
返回值
返回该对象的哈希码值。
异常
无示例:
在下面的示例中,java.util.Date.hashCode() 方法返回给定日期的哈希代码值。
import java.util.*;
public class MyClass {
public static void main(String[] args) {
//创建日期
Date Dt = new Date();
//打印日期的哈希码
System.out.print("Hash Code of the Date is: ");
System.out.print(Dt.hashCode());
}
}
上述代码的输出将是:
Hash Code of the Date is: 1269235895