Java.util.Calendar.hashCode() 方法
描述
java.util.Calendar.hashCode() 方法返回此日历对象的哈希码。
声明
以下是 java.util.Calendar.hashCode() 方法的声明
public int hashCode()
参数
NA
返回值
该方法返回此日历对象的哈希码值。
异常
NA
示例
下面的例子展示了 java.util.calendar.hashCode() 方法的使用。
package com.tutorialspoint;
import java.util.*;
public class CalendarDemo {
public static void main(String[] args) {
// create a calendar
Calendar cal = Calendar.getInstance();
// display current calendar
System.out.println("The current calendar shows: " + cal.getTime());
// get the hash code and print it
int i = cal.hashCode();
System.out.println("A hash code for this calendar is: " + i);
}
}
让我们编译并运行上面的程序,这将产生以下结果 −
The current calendar shows: Wed May 02 14:42:43 EEST 2012 A hash code for this calendar is: 53578188

