Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.util.*;

public class Main {

    public static void main(String[] args) {

        GregorianCalendar cal = (GregorianCalendar) GregorianCalendar.getInstance();

        // check if it is a leap year
        boolean isLeapYear = cal.isLeapYear(cal.get(GregorianCalendar.YEAR));
        System.out.println("Is leap year:" + isLeapYear);

        // check if 2014 is a leap year
        isLeapYear = cal.isLeapYear(2014);
        System.out.println("Is leap year:" + isLeapYear);

    }
}