我是否应该将 Java 8 接口中的静态方法显式声明为 "public static" 而不是仅 "static"?

Should I explicitly declare static methods in Java 8 interfaces as "public static" instead of "static" only?

查看 Java 8 个 API 中的某些接口(示例:Stream),我看到静态方法被声明为 public 静态,但默认方法和抽象方法不是。从技术角度来看,如果我在接口的静态方法中省略 public,我会得到一些不同的 public 访问修饰符?

The Java 8 Language specification 明确指出:

Every method declaration in the body of an interface is implicitly public. It is permitted, but discouraged as a matter of style, to redundantly specify the public modifier for a method declaration in an interface.

但是,有一个new feature coming with Java 9在于支持私有接口方法。这些私有方法对于重用默认方法可以从中受益的代码块很有用。

所以我认为 public 在 Java API 中的使用是为了使方法可见性明确的这一变化的预期精确。因此,即使 Java 8 不鼓励这样做,您也可以将其视为新的最佳实践。 延伸阅读 here.