Year equals() method in Java with Examples
The equals() method of Year class in Java is used to check if this Year object is equals to another Year object passes as a parameter. The comparison is based on the time-line position of the years.
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.
public boolean equals(Object obj)
Parameter: This method accepts a single parameter obj. It is the Year object which specifies a year with which we want to compare the current year object.
Return Value: It returns a boolean True value if the current Year object is found to be equal to the Year object passed as a parameter to it, otherwise false.
Below programs illustrate the equals() method of Year in Java: