Year compareTo(Year other) example
Description
Year compareTo(Year other)
compares this year to another year.
Syntax
compareTo
has the following syntax.
public int compareTo(Year other)
Example
The following example shows how to use compareTo
.
import java.time.Year;
/*from w ww . j av a 2 s . co m*/
public class Main {
public static void main(String[] args) {
Year y = Year.of(2014);
System.out.println(y.compareTo(Year.of(2015)));
}
}
The code above generates the following result.