Java Program to Check for Leap Year

In this Java program, you’ll learn how to Check for a leap year using the Java programming language

How to Check for a Leap Year? 

In this program, we’ll learn how to check for a leap year through JAVA program. 

There are some tricks to find whether a year is leap or not  

If a year is evenly divisible by 4, or it is evenly divisible by 100 and the last trick is if the year is divisible by 100 then it should also divisible by 400. 

import java.util.Scanner; 

public class Main { 

   public static void main(String[] args){ 

      int year; 

      System.out.println("Enter a Year : "); 

      Scanner sc = new Scanner(; 

      year = sc.nextInt(); 

      if (((year % 4 == 0) && (year % 100!= 0)) || (year%400 == 0)) 

         System.out.println("The Specified year is a leap year"); 


         System.out.println("The Specified year is not a leap year"); 




Enter a Year: 2002 

The Specified year is not a leap year.