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
廣告