int hashCode()
描述 (Description)
java.util.Calendar.hashCode()方法返回此日历对象的哈希码。
声明 (Declaration)
以下是java.util.Calendar.hashCode()方法的声明
public int hashCode()
参数 (Parameters)
NA
返回值 (Return Value)
该方法返回此日历对象的哈希码值。
异常 (Exception)
NA
例子 (Example)
以下示例显示了java.util.calendar.hashCode()方法的用法。
package com.iowiki;
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