Java Program to check if year is a LEAP year or Not

In this program we will write a Java program to check whether a year is a leap year or not. A leap year is a special year which has 1 day extra. This normal years have 365 days, however a leap year has 366 days. A leap year comes every 4 years. Here is the logic to find whether a year is a leap year or not.

The rule states:

“Every year that is exactly divisible by four is a leap year, except for years that are exactly divisible by 100, but these centurial years are leap years if they are exactly divisible by 400.”

For example,
if year = 2400, it is leap year,(Condition 1 satisfied)
but if year = 2200, is NOT a leap year, (Cond. 2 not satisfied),
and if year = 2020, is a leap year, (Cond. 2 satisfied).

To check whether a year is a leap year or not, you need to check the following 3 conditions:

1. Any year that is divisible by 400 is definitely a leap year.

2. If divisible by 4 AND not divisible by 100 then a leap year.

not a leap year.

Java program to check LEAP year –
Leap Year
Watch it on YouTube

Leave a Reply

Your email address will not be published. Required fields are marked *