Constructor in an Interface?

前端 未结 11 1059
鱼传尺愫
鱼传尺愫 2020-12-02 06:38

I know it\'s not possible to define a constructor in an interface. But I\'m wondering why, because I think it could be very useful.

So you could be sure that some fi

11条回答
  •  無奈伤痛
    2020-12-02 07:07

    This is because interfaces do not allow to define the method body in it.but we should have to define the constructor in the same class as interfaces have by default abstract modifier for all the methods to define. That's why we can not define constructor in the interfaces.

提交回复
热议问题