System.out.println(isLeapYear);
should work just fine.
Incidentally, in
else if ((year % 4 == 0) && (year % 100 == 0)) isLeapYear = false; else if ((year % 4 == 0) && (year % 100 == 0) && (year % 400 == 0)) isLeapYear = true;
the year % 400
part will never be reached because if (year % 4 == 0) && (year % 100 == 0) && (year % 400 == 0)
is true, then (year % 4 == 0) && (year % 100 == 0)
must have succeeded.
Maybe swap those two conditions or refactor them:
else if ((year % 4 == 0) && (year % 100 == 0)) isLeapYear = (year % 400 == 0);
Related Posts:
- What’s the simplest way to print a Java array?
- What’s the simplest way to print a Java array?
- Print ArrayList
- Print ArrayList
- Java – Best way to print 2D array?
- Print ArrayList
- Java – Best way to print 2D array?
- How to parse JSON boolean value?
- Print a boolean value with printf
- How to return a boolean method in java?
- Convert boolean to int in Java
- calling boolean method, heads or tails
- How to print binary tree diagram in Java?
- What is the size of a boolean variable in Java?
- Exception in thread “main” java.util.NoSuchElementException
- “Error occurred during initialization of VM; Could not reserve enough space for object heap” using -Xmx3G
- javax vs java package
- What is a stack trace, and how can I use it to debug my application errors?
- How to fix “A JNI error has occurred, please check your installation.”
- Java Runtime Environment not found error when I open an application
- “PKIX path building failed” and “unable to find valid certification path to requested target”
- What exactly does a jar file contain?
- What is the best way to implement constants in Java?
- Java optional parameters
- Understanding Spring @Autowired usage
- What is a serialVersionUID and why should I use it?
- SLF4J: Failed to load class “org.slf4j.impl.StaticLoggerBinder”
- typeof in Java 8
- Switch on Enum in Java
- error upon assigning Layout: BoxLayout can’t be shared
- Why do this() and super() have to be the first statement in a constructor?
- Else without if
- Keytool is not recognized as an internal or external command
- Cannot find “Package Explorer” view in Eclipse
- Error: Could not find or load main class in intelliJ IDE
- Java Hashmap: How to get key from value?
- Understanding the difference between null and ‘\u000’ in Java
- what does Dead Code mean under Eclipse IDE Problems Section
- restart console on Minecraft Server
- SSL peer shut down incorrectly in Java
- Java split string to array
- How can I clear or empty a StringBuilder?
- Java The method is undefined for this type
- Execution Failed for task :app:compileDebugJavaWithJavac in Android Studio
- Javamail Could not convert socket to TLS GMail
- java.net.SocketException: Connection reset
- Cannot instantiate the type Queue. Why is this?
- Pause the timer and then continue it
- Converting String Array to an Integer Array
- How to fix “unsupported class file major version 60” in IntelliJ?
- Resize an Array while keeping current elements in Java?
- Access restriction: The type ‘Application’ is not API (restriction on required library rt.jar)
- Assign the negativeCntr with the number of negative values in the linked list
- intellij incorrectly saying no beans of type found for autowired repository
- Web server failed to start. Port 8080 was already in use. Spring Boot microservice
- No Persistence provider for EntityManager named
- What does it mean: JavaFX application class must extend javafx.application.Application?
- Using Math.round to round to one decimal place?
- Hibernate Error: a different object with the same identifier value was already associated with the session
- How to solve the “failed to lazily initialize a collection of role” Hibernate exception
- Initializing multiple variables to the same value in Java
- Java: Unresolved compilation problem
- FXML Load exception
- NullPointerExcetion Native Method Accessor… Hashing Words Issue
- How to convert currentTimeMillis to a date in Java?
- How to clear console in Java – Eclipse
- Java TreeMap Comparator
- Get keys from HashMap in Java
- Determine if a String is an Integer in Java [duplicate]
- How do I run Java .class files?
- Fill an array with random numbers [duplicate]
- Java check if boolean is null
- Connection Java – MySQL : Public Key Retrieval is not allowed
- Whitespace Matching Regex – Java
- Size has private access in ArrayList
- Iterator for a linkedlist
- Hide Utility Class Constructor : Utility classes should not have a public or default constructor
- Android – Start service on boot
- JsonMappingException: No suitable constructor found for type [simple type, class ]: can not instantiate from JSON object
- Sending POST data in Android
- When is “java.io.IOException:Connection reset by peer” thrown?
- Java ArrayList of Doubles
- Regex pattern including all special characters
- Error: ‘)’ expected compiler error
- How does addNotify() and requestFocus() work in Java with JPanel?
- DTO and DAO concepts and MVC
- How to extract .war files in java? ZIP vs JAR
- What is the difference between run-time error and compiler error?
- What is the difference between ArrayList.clear() and ArrayList.removeAll()?
- Java says this method has a constructor name
- Test if element is present using Selenium WebDriver?
- Increase heap size in Java
- android.content.res.Resources$NotFoundException: String resource ID #0x0
- what does x– or x++ do here?
- How to print a table of information in Java
- set background color: Android
- Class Declarations for temperature program in Java
- Spring Boot – Cannot determine embedded database driver class for database type NONE
- Convert double to float in Java
- Can’t seem to disable Java Automatic Update