Calendar hashCode() in Java

hashCode(): This method is available in java.util.Calendar class of Java.

Syntax:

int java.util.Calendar.hashCode()

This method returns a hash code for this calendar.

Parameters: NA

Returns: a hash code value for this object.

Exceptions: NA

Approach

Java

import java.util.Calendar;

public class CalendarhashCode {
    public static void main(String[] args) {

        // create a calendar
        Calendar calendar = Calendar.getInstance();
        calendar.add(Calendar.DATE, 2);

        System.out.println(calendar.hashCode());
    }
}

Output:

1685175307


No comments:

Post a Comment