A leap year is a calendar year with an extra day on February 29th. A year with an extra day. It has 366 days instead of the standard 365. If the year is divisible by 4 but not by 100, or if the year is divisible by 400, it is a leap year. The purpose of the leap year calculation is to compensate for the mismatch between the earth rotation time and the day hours. In this post, we’ll look at how to create a Java programme that checks the leap year.

## Leap Year

A leap year is one whose year number is exactly divisible by four, or by 400 in the case of the final year of a century: The extra day, February 29, compensates for the time lost annually when the approximate 365 1/4 day cycle is calculated as 365 days: A leap year is one whose year number is exactly divisible by four, or by 400 in the case of the final year of a century.

package in.yawin; public class LeapYear { public static void main(String[] args) { int year = 2000; if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0) { System.out.println(year + " is a leap year."); } else { System.out.println(year + " is not a leap year."); } } }

### Output

2000 is a leap year.

## Explanation

A leap year is one that is divisible by four. Consider the year 2016. When you divide 2016 by 4, the remainder is 0. It is a leap year in 2016.

Another example is that the year 2100 is divisible by four. However, 2100 is also divisible by 100. The year 2100 is not a leap year in this case.

It is a leap year in 2000. The year 2000 can be divided by four. However, 2000 is also divisible by 100. Another requirement is that the year 2000 be divisible by 400. As a result, the year 2000 is a leap year.