You are here: Home / Topics / Program to find leap year in Java

Program to find leap year in Java

Filed under: Java on 2023-08-12 20:46:26

// Program to find given year is leap year or not

class  Leap2
{
public static void main( String args[ ] )
{
 int y;

 y = 2016;

 if( y % 100 == 0 )
 {
  if( y % 400 == 0 )
   System.out.println( " It is a LEAP Year." );
  else
   System.out.println( " It is NOT a LEAP Year." );
 }
 else if( y % 4 == 0 )
  System.out.println("It is a LEAP Year." );
 else
  System.out.println( " It is NOT a LEAP Year." );
}
}


Output:

It is a LEAP Year.

About Author:
J
Java     View Profile
Hi, I am using MCQ Buddy. I love to share content on this website.