接口类无class关键字. 以interface代替,无构造函数。外部使用implements,他们没有明确的继承关系
public interface Obj {
public abstract void log();
public abstract void add();
public abstract void sub();
}
public class Test11A implements Obj {
public int x;
public Test11A()
{
System.out.println("Test11构造");
}
public static void main(String[] args) {
Test11A test11a = new Test11A();
test11a.add();
test11a.log();
System.out.println("hello");
}
@Override
public void log() {
System.out.println(x);
}
@Override
public void add() {
x++;
}
@Override
public void sub() {
x--;
}
}