The length() method of Year class in Java is used to return the length of this year object’s value in number of days. There can be only two possible lengths of Year, 365(Non-leap years) and 366(Leap years).
public int length()
Parameter: This method does not accepts any parameter.
Return Value: It returns an integer value denoting the length of Year in number of days.
Below programs illustrate the length() method of Year in Java:
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.