is there a way to add a default constructor to an interface

前端 未结 5 1190
梦如初夏
梦如初夏 2021-02-14 12:26

With default methods now added to Java 8, is there any way to create a default constructor?

I\'ve tried:

public interface KadContent
{
    publ         


        
5条回答
  •  野的像风
    2021-02-14 12:46

    Yes, kind of! You can do:

    public interface MyInterface {
      MyInterface NO_OP = new MyInterface() {};
    }
    

提交回复
热议问题