public static void main(String[] args) { Inter i = new Demo(); i.print(); System.out.println(Inter.num); } } interface Inter { public static final int num = 10; //public Inter(){} 接口中没有构造方法 /*public void print() {} 接口中不能定义非抽象方法*/ public abstract void print(); } class Demo /*extends Object*/ implements Inter { //一个类不写继承任何类,默认继承Object类 public void print() { System.out.println(num); } public Demo() { super(); } |