boolean equals(Object otherYear)
描述 (Description)
java.time.Year.equals(Year otherYear)方法检查此Year是否等于指定的Year。
声明 (Declaration)
以下是java.time.Year.equals(Year otherYear)方法的声明。
public int equals(Year otherYear)
参数 (Parameters)
otherYear - 另一年,null返回false。
返回值 (Return Value)
如果另一年等于这一年,则为true。
例子 (Example)
以下示例显示了java.time.Year.equals(Year otherYear)方法的用法。
package com.iowiki;
import java.time.Year;
public class YearDemo {
public static void main(String[] args) {
Year date = Year.of(2005);
Year date1 = Year.of(2006);
System.out.println(date.equals(date1));
}
}
让我们编译并运行上面的程序,这将产生以下结果 -
false