GregorianCalendar class equals(Object obj) method example

Compares this GregorianCalendar to the specified Object.


GregorianCalendarclass equals(Object obj) method example. This example shows you how to use equals(Object obj) method.This method Compares this GregorianCalendar to the specified Object.

Here is the code:-

/**
 * @Program that Compares this GregorianCalendar to the specified Object.
 * Equals.java 
 * Author:-RoseIndia Team
 * Date:-27-May-2008
 */
import java.util.*;
public class Equals {
public static void main(String[] args) {
//Creating a Calendar    
GregorianCalendar g=new GregorianCalendar(2004,6,23);
GregorianCalendar g1=new GregorianCalendar(2005,4,15);
GregorianCalendar g2=new GregorianCalendar(2005,4,15);
//  Compares GregorianCalendar g to the specified Object g1.
boolean b=g.equals(g1);
System.out.println("Equals: "+b);
// Compares GregorianCalendar g1 to the specified Object g2.
boolean b1=g1.equals(g2);
System.out.println("Equals: "+b1);

    }

}

Output of the program:-
Equals: false
Equals: true

Post Comment
Name:
E-mail:
Contact no :
Comments:
  Refresh Image
Verify Image:
 
 
Your Comment's
 
 
 

HOME | COPYRIGHT | CONTACT US