A leap year (in the Gregorian calendar) occurs:
Some examples:
For a delightful, four-minute explanation of the whole phenomenon of leap years, check out this YouTube video.
Your task is to determine whether a given year is a leap year.
Before you start, make sure you understand how to write code that can pass the test cases. For more context, check out this tutorial.
Most Java exercises include multiple test cases. These cases are structured to support a useful process known as test-driven development (TDD). TDD involves repeating a structured cycle that helps programmers build complex functionality piece by piece rather than all at once. That cycle can be described as follows:
The test files in this track contain all the tests your solution should pass to be considered valid. That doesn't immediately seem to be compatible with the cycle described above, in which tests are written one by one. However, the tool that we use to write our tests, JUnit, provides a @Disabled annotation that can be used to temporarily skip an already-written test. Using this annotation, we make sure that the test files we deliver to you satisfy the following rules:
This allows you to simulate the TDD cycle by following these slightly-modified steps:
@Disabled
annotation in the test file.Sign up to Exercism to learn and master Java with 25 concepts, 148 exercises, and real human mentoring, all for free.
Deep dive into the different algorithms and approaches you can use to solve Leap, as Jeremy and Erik explore interesting Community Solutions across 10 different languages on Exercism.