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 notpublic 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;elseleap = false;}elseleap = true;}elseleap = false;if(leap)System.out.println(year + " is a leap year.");elseSystem.out.println(year + " is not a leap year.");}}
Output:
2019 is not a leap year.