YearMonth equals(Object obj) example
Description
YearMonth equals(Object obj)
checks if this year-month is equal to another year-month.
The comparison is based on the time-line position of the year-months.
Syntax
equals
has the following syntax.
public boolean equals(Object obj)
Example
The following example shows how to use equals
.
import java.time.YearMonth;
/* w w w . ja v a2 s . c o m*/
public class Main {
public static void main(String[] args) {
YearMonth y = YearMonth.now();
System.out.println(y.equals(YearMonth.now()));
}
}
The code above generates the following result.