GregorianCalendar equals(Object) in Java

equals(Object): This method is available in java.util.GregorianCalendar class of Java.

Syntax:

boolean java.util.GregorianCalendar.equals(Object obj)

This method takes one argument. This method compares this GregorianCalendar to the specified Object.

Note: The result is true if and only if the argument is a GregorianCalendar object that represents the same time value.

Parameters: One parameter is required for this method.

obj: the object to compare with.

Returns: true if this object is equal to obj; false otherwise.

Exceptions: NA

Approach

Java

import java.util.GregorianCalendar;

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

        GregorianCalendar cal = new GregorianCalendar();
        GregorianCalendar anotherCalendar =
new GregorianCalendar();

        System.out.println(cal.equals(anotherCalendar));
    }
}

Output:

false


No comments:

Post a Comment