目录

int hashCode()

描述 (Description)

java.util.GregorianCalendar.hashCode()方法为此GregorianCalendar对象生成哈希码。

声明 (Declaration)

以下是java.util.GregorianCalendar.hashCode()方法的声明

public int hashCode()

参数 (Parameters)

NA

返回值 (Return Value)

此方法返回此对象的哈希码值。

异常 (Exception)

NA

例子 (Example)

以下示例显示了java.util.GregorianCalendar.hashCode()方法的用法。

package com.iowiki;
import java.util.*;
public class GregorianCalendarDemo {
   public static void main(String[] args) {
      // create a new calendar
      GregorianCalendar cal = (GregorianCalendar) GregorianCalendar.getInstance();
      // print the current date and time
      System.out.println("" + cal.getTime());
      // print a hashcode for this calendar
      System.out.println("Hash Code:" + cal.hashCode());
   }
}

让我们编译并运行上面的程序,这将产生以下结果 -

Fri May 18 13:18:55 EEST 2012
Hash Code:1360560473
↑回到顶部↑
WIKI教程 @2018