class Demo1_Interface {
public static void main(String[] args) {
Demo d = new Demo();
d.print();
}
}
interface Inter {
public static final int num = 10;
public abstract void print();
}
class Demo implements Inter {
public void print() {
System.out.println(num);
}
public Demo() {
super();
}
}
类实现接口,跟继承一样,类中的构造方法不是要访问接口中的构造么?那为什么还说接口中没有构造方法呢? |
|