Java Program to Check if the Year is a Leap Year or Not

Check if a Year is a Leap Year or Not in Java

Given an integer input for a year, the objective is to check whether the given integer input represents a Leap year or not. In order to do so, we’ll check for two conditions, any year to be a leap year must satisfy either of them.


Input: 2020

Output: It's a Leap Year

Flow Diagram:-

Leap year or not.png


  • step 1: Start

  • step 2: Read year

  • step 3: if year%4=0 and year%100!=0 or if year%4=0 and year%400=0 then go to step 4
    else go to step5

  • step 4: print a leap year

  • step 5: print not a leap year

  • step 6: Stop



public class Main
   public static void main (String[]args)

     int year = 2020;

     if (year % 400 == 0)
       System.out.println (year + " is a Leap Year");

     else if (year % 4 == 0 && year % 100 != 0)
       System.out.println (year + " is a Leap Year");

         System.out.println (year + " is not a Leap Year");




2100 is not a Leap Year