當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


Java 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 與此相同,則為 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

相關用法


注:本文由純淨天空篩選整理自 java.time.YearMonth.equals() Method Example。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。