Year isLeap() method in java with example

Let’s learn Year isLeap() method in java with example.

Year isLeap() method in java with example

Here we are going to learn leap year program using isLeap() method. isLeap() method is of class Year.

Syntax:

public boolean isLeap()

Returns: true if the year is leap, false otherwise.

Checks if the year is a leap year, according to the ISO proleptic calendar system rules. Let’s see java program to illustrate leap year using isLeap() method.

import java.time.Year;
public class IsLeapYear 
{
   public static void main(String[] args) 
   {
      // creating Year object
      Year obj = Year.of(2005);
      // check if given year a leap year or not 
      System.out.println(obj.isLeap());
   }
}


Output:

false


Also read – strings in java