OffsetTime equals() method in Java with examples
The equals() method of OffsetTime class in Java checks if this time is equal to another time. returns true if they are equal or false if they are not.
public boolean equals(Object obj)
Parameter: This method accepts a single mandatory parameter obj which specifies the other time which will be compared with.
Return Value: It returns true if both the time are equal, else it returns false.
Below programs illustrate the equals() method:
Program 1 :
time1: 15:30:30+07:00 time1: 15:30:30+07:00 time1 when compared to time2 returns: true
Program 2 :
time1: 15:30:30+07:00 time1: 12:10:30+07:00 time1 when compared to time2 returns: false
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.