接口在Java中有构造函数吗?
问题描述:
我知道Java中的接口由虚拟机作为抽象类处理。因此,Java中的每个类,抽象与否都有一个构造函数。这是否意味着接口也有构造函数?因为一方面我也有理由拥有一个构造函数,因为它们是抽象类。另一方面,它没有意义,因为接口没有任何初始化属性。
那么它实际上是如何工作的?
I know that interfaces in Java are handled by the virtual machine as abstract classes. So, every class in Java, abstract or not has a constructor. Does this mean that interfaces have a constructor too? Because too me on one hand makes sense to have a constructor since they are abstract classes. On the other hand it doesn´t make sense since interfaces don´t have any attributes to initialize. So how does it actually work?
答
接口没有构造函数。他们的实现做。
Interfaces don't have constructors. Their implementations do.