java.time.YearMonth.equals(YearMonth otherYearMonth)方法檢查此YearMonth是否等於指定的YearMonth。
聲明
以下是java.time.YearMonth.equals(YearMonth otherYearMonth)方法的聲明。
public int equals(YearMonth otherYearMonth)
參數
otherYearMonth- 另一個YearMonth,如果是null則返回false。
返回值
如果另一個YearMonth等於此年月,則返回true。
示例
以下示例顯示了java.time.YearMonth.equals(YearMonth otherYearMonth)方法的用法。
package com.zaixian;
import java.time.YearMonth;
public class YearMonthDemo {
public static void main(String[] args) {
YearMonth date = YearMonth.of(2005,11);
YearMonth date1 = YearMonth.of(2006,12);
System.out.println(date.equals(date1));
}
}
編譯並運行上面的程式,這將產生以下結果 -
false
上一篇:
java.time.YearMonth類
下一篇:
java.time.ZonedDateTime類
