package com.bitsoft.inner;
interface Person {
public void print();
}
class Demo {
public void fun(Person per) {
per.print();
}
public void get() {
this.fun([color=red][b]new Person() {
public void print() {
System.out.println("我是一个学生.");
}
}[/b][/color]);
}
}
public class OODemo {
/**
* @param args
*/
public static void main(String[] args) {
new Demo().get();
}
}
匿名内部类实现了Person接口

被折叠的 条评论
为什么被折叠?



