Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

leap year program in java

public static boolean isLeapYear(int year) {
  if (year % 4 != 0) {
    return false;
  } else if (year % 400 == 0) {
    return true;
  } else if (year % 100 == 0) {
    return false;
  } else {
    return true;
  }
}
Comment

java leap year expression

(year % 4 == 0) && ((year % 100 != 0) || (year % 400 == 0))
Comment

java leap year

  public static void main(String[] args) {
        int year = 2005;

        if ((year % 400 == 0) || ((year % 4 == 0) && (year % 100 != 0))){
            System.out.println(year+" leap year");
        }else {
            System.out.println(year+" not a leap year");
        }
    }
Comment

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;
  }
}
Comment

java leap years


public static boolean isLeapYear(int year) {
  Calendar cal = Calendar.getInstance();
  cal.set(Calendar.YEAR, year);
  return cal.getActualMaximum(Calendar.DAY_OF_YEAR) > 365;
}

Comment

PREVIOUS NEXT
Code Example
Java :: combine two array in java 
Java :: in java how to compare two strings 
Java :: Quick Sort Java Implementation 
Java :: class declaration in java 
Java :: java program to Check given String is contians number or not 
Java :: the main of java 
Java :: how to change a character in a string in java with ascii 
Java :: java http response code 
Java :: find last element in array in java 
Java :: The this(Keyword) 
Java :: jdk path 
Java :: check if field exists in java 
Java :: zweidimensionales array ausgeben java 
Java :: filter and map multiple fields from java stream 
Java :: even and odd java & 
Java :: binary search java 
Java :: reverse negative number 
Java :: java sort a map by keys 
Java :: java pointer 
Java :: java stringbuilder setcharat 
Java :: write message in file java 
Java :: variables inside strings kotlin 
Java :: spring xml configuration 
Java :: copy linked list 
Java :: get role assigned to a user inside spring controller 
Java :: single dex file error android 
Java :: Implementing the ArrayList Class in java list 
Java :: ArrayList of prime numbers 
Java :: linked list vs array list 
Java :: do function after time android studio 
ADD CONTENT
Topic
Content
Source link
Name
3+2 =