目录

int hashCode()

描述 (Description)

java.util.Date.hashCode()方法返回此Date对象的哈希码。

声明 (Declaration)

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

public int hashCode()

参数 (Parameters)

NA

返回值 (Return Value)

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

异常 (Exception)

NA

例子 (Example)

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

package com.iowiki;
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
↑回到顶部↑
WIKI教程 @2018