boolean leap year java with input code example
Example 1: java leap years
public static boolean isLeapYear(int year) {
if (year % 4 != 0) {
return false;
} else if (year % 100 != 0) {
return true;
} else if (year % 400 != 0) {
return false;
} else {
return true;
}
}
Example 2: java leap year expression
(year % 4 == 0) && ((year % 100 != 0) || (year % 400 == 0))