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接口
java_匿名内部类
最新推荐文章于 2025-08-15 23:10:13 发布