public class ReturnValue { public static void main(String[] args) { for (int year = 1890; year < 1910; ++year) { System.out.println(year + " " + leap(year)); } } //Return true if the year is a leap year, false otherwise. private static boolean leap(int year) { if (year == 0) { System.err.println("There was no Year Zero."); System.exit(1); } /* 1600 and 2000 were leap years, but 1700, 1800, and 1900 weren't. && has higher precedence than ||. */ if (year % 400 == 0 || year % 100 != 0 && year % 4 == 0) { return true; } return false; /* Actually, all we need to say was return year % 400 == 0 || year % 100 != 0 && year % 4 == 0; */ } }