Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

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 check if year is leap

      boolean isLeap =  new GregorianCalendar().isLeapYear(2020);
      //returns true
Comment

Leap year or not program in java using if-else

import java.util.Scanner;public class Main{public static void main(String[] args){int year;System.out.println("Enter the year");Scanner sc = new Scanner(System.in);year = sc.nextInt();if (((year % 4 == 0) && (year % 100!= 0)) || (year%400 == 0))System.out.println("it is a leap year");elseSystem.out.println("it is not a leap year");}}
Comment

PREVIOUS NEXT
Code Example
Java :: video compression with java 
Java :: afficher matrice java 
Java :: scanf in java 
Java :: dockerfile spring boot 
Java :: Java Enabling Assertions 
Java :: jsp check if request parameter exists 
Java :: transparent card background android 
Java :: isnumeric matches in java 
Java :: split string into array java 
Java :: dependency injection java 
Java :: java stream map int to char 
Java :: treeset java descending order using comparator 
Java :: functional interface java 
Java :: how to get app categories android packagemanager 
Java :: java local function 
Java :: spring boot api key authentication example 
Java :: how to call same activity again in android 
Java :: sort arrays by first element java 
Java :: java empty array list vs null elements 
Java :: prime factorization java 
Java :: seek bar 
Java :: java do while loop 
Java :: jda documentation discord 
Java :: Traversing through java map foreach 
Java :: index 1 out of bound for length 1 java 
Java :: java delete element from list 
Java :: Java Access Array Elements 
Java :: creating an object in java 
Java :: interface vs abstract class java 
Java :: java hex to rgb 
ADD CONTENT
Topic
Content
Source link
Name
7+8 =