java.util.Date.hashCode()%uA0方法返回此Date对象的哈希代码。
声明
以下是java.util.Date.hashCode()方法的声明
public int hashCode()
参数
-
NA
返回值
该方法返回此Date对象的哈希码值。
异常
-
NA
例子
下面的示例演示java.util.Date.hashCode()方法的用法。
package com.yiibai 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