Period equals() method in Java with Examples
The equals() method of Period class in Java is used to check if two given periods are equal or not.
The comparison is based on the type Period and each of the three years, months and date. To be equal, all of the three year, month and date must be individually equal.
public boolean equals(Period secondPeriod)
Parameters: This method accepts a single parameter secondPeriod which is the another period to compare with.
Return Value: The above methods returns true if given periods are equal, else it returns false.
Below programs illustrate the above method:
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.