isLeapYear(int): This method is available in java.util.GregorianCalendar class of Java.
Syntax:
boolean java.util.GregorianCalendar.isLeapYear(int year)
This method takes one argument of type int as its parameter. This method determines if the given year is a leap year. Returns true if the given year is a leap year.
Parameters: One parameter is required for this method.
year: the given year.
Returns: true if the given year is a leap year; false otherwise.
Exceptions: NA
Approach
Java
import java.util.GregorianCalendar;public class GregorianCalendarisLeapYear {public static void main(String[] args) {GregorianCalendar cal = new GregorianCalendar();int year = 2024;System.out.println(cal.isLeapYear(year));}}
Output:
true
No comments:
Post a Comment