为 Instant
类编写的 < em > Oracle 教程 页面显示了以下示例代码:
Instant oneHourLater = Instant.now().plusHours(1);
当我尝试编译这段代码时,编译器会抛出错误:
InstantPrint.java:6: error: cannot find symbol Instant oneHourLater = Instant.now().plusHours(1); ^ symbol: method plusHours(int) location: class Instant
但是这个 Java 文档提到了 plusHours()
方法,但是我检查了这个 Instant
类,它不包含 plusHours()
方法。
此后,为什么在示例中提到这个 plusHours()
方法?