Java Program to Check Leap Year
In this example, we are giving a program to check a year is leap year or not.
To check a year is leap year or not:
# To check a year is leap year or not
public class Largest {
public static void main(String[] args) {
int year = 2019;
boolean leap = false;
if (year % 4 == 0) {
if (year % 100 == 0) {
if (year % 400 == 0)
leap = true;
else
leap = false;
}
else
leap = true;
}
else
leap = false;
if(leap)
System.out.println(year + " is a leap year.");
else
System.out.println(year + " is not a leap year.");
}
}
Output:
2019 is not a leap year.