Java Program to Check Whether Year Is Leap Year or Not

Java program to check whether year is Leap year or not

//Java program to check whether year is Leap year or not.
import java.util.*;
class LeapYear
    public static void main(String []s)
        int year;
        Scanner sc=new Scanner (;
            System.out.print("Enter year:");
            if((year%400==0)||(year%100!=0 && year%4==0))
                System.out.println(year+" is a Leap Year.");
                System.out.println(year+" is not a Leap Year.");
        catch (Exception Ex)
            System.out.println("Oops ... : " + Ex.toString());


    Complie 	:	javac
    Run		:	java LeapYear
    First Run:
    Enter year:2000
    2000 is a Leap Year.

    Second Run:
    Enter year:2100
    2100 is not a Leap Year.

    Third Run:
    Enter year:2004
    2004 is a Leap Year.

    Fourth Run:
    Enter year:2005
    2005 is not a Leap Year.
Share on:

Hi, I'm Ranjith a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coding Diksha. Here, I post about programming to help developers.

Leave a Comment