There is no constructor for interface in Java?

前端 未结 6 586
深忆病人
深忆病人 2020-12-17 06:48

In Java, if I have an interface:

public interface MyInterface{
}

Then MyInterface implementation is:

class MyC         


        
6条回答
  •  生来不讨喜
    2020-12-17 07:19

    You can't instantiate an interface directly. You need to use an instance of an implementing class:

    myClass mine = new myClassImpl();
    

提交回复
热议问题