标签:oid system lang font static div new ons tty
public class TestUSB {
public static void main(String[] args) {
Computer c = new Computer();
c.works(new USB() {//接口是没有构造器的,这里不能看作构造器,而是实现接口的匿名类
@Override
public void work() {
System.out.println("====anonymous usb working====");
}
});
}
}
class Computer {
public void works(USB u) {
u.work();
System.out.println("====device working====");
}
}
interface USB {
void work();
}
标签:oid system lang font static div new ons tty
原文地址:http://www.cnblogs.com/chendifan/p/6535603.html