abstract class Student{
 abstract void speak();
}
class Teacher{
 void look(Student stu){
  stu.speak();
 }
}
public class Example5_16{
 public static void main(String arg[]){
  Teacher zhang=new Teacher();
  zhang.look(new Student(){
   void speak(){
    System.out.println("这是匿名类中的方法");
   }
  }
  );
 }
 
}

interface Show{
 public void show();
}
class A{
 void f(Show s){
  s.show();
 }
}
public class Example5_17{
 public static void main(String arg[]){
  A a=new A();
  a.f(new Show(){
   public void show(){
    System.out.println("这是实现了接口的匿名类");
   }
  });
 }
}