class Test6 {
public static void main(String[] args) {
new Inter() {
public void show() {
System.out.println("show");
}
}.show();
new Person().method(new Inter() {
public void show() {
System.out.println("show2");
}
});
new Person().eat().show();
}
}
interface Inter {
public void show();
}
class Person implements Inter {
public void show() {
System.out.println("show");
}
public void method(Inter i) {
i.show();
System.out.println("method");
}
public Inter eat() {
return new Inter() {
public void show() {
System.out.println("eat");
}
};
}
}
|
|