Full Stack Web Development Internship Program
- 29k Enrolled Learners
- Weekend/Weekday
- Live Class
I am pretty sure everyone of you must have heard about the term, Leap Year! A leap year has 366 days which occurs once in every 4 years. This additional day in the leap year is added in the month of February. Well, in this article I am going to brief you on how to implement leap year program in Java.
The agenda for this concept is going to be as follows:
A leap year has 366 days. Now, there are certain conditions to check whether a year is a leap year or not! Let’s have a look at them:
Now that you are well aware of the concept, let us implement it through a Java code.
Here’s a java code to implement leap year program in java:
class Test { static boolean Year(int year) { if (year % 400 == 0) return true; if (year % 100 == 0) return false; if (year % 4 == 0) return true; return false; } public static void main(String[] args) { int year = 2018; System.out.println( Year(2018)? "Leap Year" : "Not a Leap Year" ); } }
Here, you witnessed how easily we implemented our concept in Java.
I hope you are clear with the concept of Leap Year in Java now. Keep reading, keep exploring!
With this, we come to an end of this blog on “leap year program in java”. I hope it added value to your knowledge of java .
Now that you have understood Java code, check out the Java training by Edureka, a trusted online learning company with a network of more than 250,000 satisfied learners spread across the globe. Edureka’s Java J2EE and SOA training and certification course is designed for students and professionals who want to be a Java Developer. The course is designed to give you a head start into Java programming and train you for both core and advanced Java concepts along with various Java frameworks like Hibernate & Spring.
Got a question for us? Please mention it in the comments section of this “leap year program in java” blog and we will get back to you as soon as possible.
Course Name | Date | Details |
---|---|---|
Java Course Online | Class Starts on 7th December,2024 7th December SAT&SUN (Weekend Batch) | View Details |
edureka.co