Calendar class equals(Object obj)method example
Calendar class equals(Object obj)method example. This example shows you how to use equals(Object obj) method.This method Compares this Calendar to the specified Object.
Here is the code:-
/**
* @Program that Compares this Calendar to the specified Object.
* equalscalender.java
* Author:-RoseIndia Team
* Date:-22-May-2008
*/
import java.util.*;
public class equalscalender {
public static void main(String[] args) {
//Creating a calender
Calendar c = Calendar.getInstance() ;
Calendar c1 = new GregorianCalendar(2005,05,23);
// Compares this Calendar to the specified Object.
boolean b = c.equals(c1);
//returns true if equals else return false
System.out.println("C and C1 are equal:- "+b);
}
} |
Output of the program:-
| C and C1 are equal:- false |
|