Why can't static methods be abstract in Java?

后端 未结 25 2183
不思量自难忘°
不思量自难忘° 2020-11-22 08:34

The question is in Java why can\'t I define an abstract static method? for example

abstract class foo {
    abstract void bar( ); // <-- this is ok
    ab         


        
25条回答
  •  南笙
    南笙 (楼主)
    2020-11-22 08:57

    You can do this with interfaces in Java 8.

    This is the official documentation about it:

    https://docs.oracle.com/javase/tutorial/java/IandI/defaultmethods.html

提交回复
热议问题