Illegal static interface method call

后端 未结 1 1378
旧时难觅i
旧时难觅i 2020-12-17 21:37

Java-8 allows define static methods inside interface, but restricts it invocation by only interface name:

9.4: An interface can declare static methods

相关标签:
1条回答
  • 2020-12-17 21:46

    It's a fairly strong consensus that the syntax in question shouldn't have been allowed for static methods on classes, either, but by the time that was realized it was too late to change. It wasn't too late for the recently added interface methods.

    Additionally, permitting this syntax would introduce the possibility of the diamond problem, as a class could implement interfaces defining colliding methods.

    0 讨论(0)
提交回复
热议问题