Java.util.Calendar.hashCode() Method



Description

The java.util.Calendar.hashCode() method returns a hash code for this calendar object.

Declaration

Following is the declaration for java.util.Calendar.hashCode() method

public int hashCode()

Parameters

NA

Return Value

The method returns a hash code value for this calendar object.

Exception

NA

Example

The following example shows the usage of java.util.calendar.hashCode() method.

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);
   }
}

Let us compile and run the above program, this will produce the following result −

The current calendar shows: Wed May 02 14:42:43 EEST 2012
A hash code for this calendar is: 53578188
java_util_calendar.htm
Advertisements