
- java.time 包類
- java.time - 主頁
- java.time - 時鐘
- java.time - 持續時間
- java.time - 時刻
- java.time - 本地日期
- java.time - 本地日期時間
- java.time - 本地時間
- java.time - 月日
- java.time - 偏移日期時間
- java.time - 偏移時間
- java.time - 週期
- java.time - 年
- java.time - 年月
- java.time - 區域日期時間
- java.time - 區域識別符號
- java.time - 區域偏移量
- java.time 包列舉
- java.time - 月
- java.time 有用資源
- java.time - 討論
java.time.YearMonth.equals() 方法示例
說明
**java.time.YearMonth.equals(YearMonth otherYearMonth)** 方法檢查此 YearMonth 是否等於指定的 YearMonth。
宣告
以下是 **java.time.YearMonth.equals(YearMonth otherYearMonth)** 方法的宣告。
public int equals(YearMonth otherYearMonth)
引數
**otherYearMonth** - 另一個 YearMonth,null 返回 false。
返回值
如果另一個 YearMonth 等於此 YearMonth,則返回 true。
示例
以下示例顯示了 java.time.YearMonth.equals(YearMonth otherYearMonth) 方法的使用。
package com.tutorialspoint; 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
廣告