To find if a year is a leap year in Java, you can use an if statement to check if the year is divisible by 4, but not by 100, or if it is divisible by 400.
Here's an example of how to find if a year is a leap year in Java:
ferer to:lautturi.comint year = 2020; 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"); }
In the above example, an if statement is used to check if the year is divisible by 4, but not by 100, or if it is divisible by 400. If either of these conditions is true, the year is a leap year and a message is printed to the console. If neither condition is true, the year is not a leap year and a different message is printed.
Keep in mind that this algorithm follows the standard rules for determining leap years. However, there are some exceptions to these rules for certain historical and astronomical calendars.