Answers for "leap year or not java"

2

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;
  }
}
Posted by: Guest on January-25-2021
0

java check if year is leap

boolean isLeap =  new GregorianCalendar().isLeapYear(2020);
      //returns true
Posted by: Guest on February-21-2021

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language