equals(Object): This method is available in java.util.Calendar class of Java.
Syntax:
boolean java.util.Calendar.equals(Object obj)
This method takes one argument. This method compares this Calendar to the specified Object. The result is true if and only if the argument is a Calendar object of the same calendar system that represents the same time value under the same Calendar parameters as this object.
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.Calendar;public class Calendarequals {public static void main(String[] args) {// create a calendarCalendar calendar = Calendar.getInstance();Calendar anotherCalendar = Calendar.getInstance();anotherCalendar.add(Calendar.DATE, 1);System.out.println(calendar.equals(anotherCalendar));}}
Output:
false
No comments:
Post a Comment