Why can't I define a static method in a Java interface?

后端 未结 24 1692
没有蜡笔的小新
没有蜡笔的小新 2020-11-22 05:44

EDIT: As of Java 8, static methods are now allowed in interfaces.

Here\'s the example:

public interface IXMLizable         


        
24条回答
  •  深忆病人
    2020-11-22 06:40

    Commenting EDIT: As of Java 8, static methods are now allowed in interfaces.

    It is right, static methods since Java 8 are allowed in interfaces, but your example still won't work. You cannot just define a static method: you have to implement it or you will obtain a compilation error.

提交回复
热议问题