java.time.Period.equals() 方法示例



描述

java.time.Period.equals() 方法检查此 Period 是否等于指定的 Period。

声明

以下是 java.time.Period.equals() 方法的声明。

public int equals(Period otherPeriod)

参数

otherPeriod - 其他 Period,null 返回 false。

返回值

如果其他 Period 等于此 Period,则返回 true。

示例

以下示例演示了 java.time.Period.equals() 方法的用法。

package com.tutorialspoint;

import java.time.Period;

public class PeriodDemo {
   public static void main(String[] args) {

      Period period = Period.ofDays(5);
      Period period1 = Period.ofDays(6);
      System.out.println(period.equals(period1));
   }
}

让我们编译并运行上述程序,结果如下所示 -

false
广告
© . All rights reserved.