Duration equals(Duration) method in Java with Examples
The equals(Duration) method of Duration Class in java.time package is used to check whether this duration is equal to the duration passed as the parameter.
public boolean equals(Duration otherDuration)
Parameters: This method accepts a parameter otherDuration which is the duration to which this duration will be compared to.
Return Value: This method returns a boolean value showing whether this Duration is equal to the otherDuration or not.
Below examples illustrate the Duration.equals() method:
Reference: Oracle Doc
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.