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 :: how to switch between two stylesheets in javafx. 
Java :: java write number with variable decimal 
Java :: tinyint in java 
Java :: mysqld always running 
Java :: using for each loop for searching in array 
Java :: java stack declaration 
Java :: Java Labeled continue Statement Java 
Java :: java operations on classes 
Java :: banner generator spring boot 
Java :: HOW TO CODE WORKING PLUGIN IN MINECRAFT 
Java :: OCA Exam Questions 
Java :: java singleton with synchronized 
Java :: What is accept() method in networking 
Java :: media style dependency androidx 
Java :: jwt token in android studio 
Java :: leetspeak 
Java :: Magic square java user input 
Java :: final java 
Java :: Join Two Variables Together In Java 
Java :: turn on device location android programmatically 
Java :: react-native maven package 404 not found 
Java :: what is a producedure java 
Java :: opencv copy image java 
Java :: free pearson uk textbooks 
Java :: java.sql.SQLException: Invalid column index 
Java :: java find view by id 
Java :: ignore sonarlint line java 
Java :: younger brother of java 
Java :: connect 2 package in android 
Java :: java Difference Array | Range update query in O(1) 
ADD CONTENT
Topic
Content
Source link
Name
7+1 =