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

后端 未结 24 1507
没有蜡笔的小新
没有蜡笔的小新 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:43

    • "Is there a particular reason that static methods cannot be overridden".

    Let me re-word that question for your by filling in the definitions.

    • "Is there a particular reason that methods resolved at compile time cannot be resolved at runtime."

    Or, to put in more completely, If I want to call a method without an instance, but knowing the class, how can I have it resolved based upon the instance that I don't have.

提交回复
热议问题