问个关于java接口的简单问题
这是一个接口:
package com.artima.security.doer;
public interface Doer {
void doYourThing();
}
这是实现了接口的一个类:
public class Friend implements Doer {
private Doer next;
private boolean direct;
public Friend(Doer next, boolean direct) {
this.next = next;
this.direct = direct;
}
public void doYourThing() {
if (direct) {
next.doYourThing();
}
else {
AccessController.doPrivileged(
new PrivilegedAction() {
public Object run() {
next.doYourThing();
return null;
}
}
);
}
}
}
我不明白private Doer next;怎么能定义一个接口的变量,而且next.doYourThing();还调用了接口的方法,doYourThing在接口里根本都没实现阿?