例5-17和例5-18
interface Show{
public void show();
}
class A{
void f(Show s){
s.show();
}
}
public class Example5_17 {
public static void main(String[] args) {
A a=new A();
a.f(new Show(){
public void show(){
System.out.println("这是实现了接口的匿名类");
}
});
}
}
public class Example5_18{
public static void main(String args[]){
int n=0,m=0,t=0;
try{
t=9999;
m=Integer.parseInt("8888");
n=Integer.parseInt("12s3a");
System.out.println("我没有机会输出");
}
catch(Exception e){
System.out.println("发生异常");
n=123;
}
System.out.println("n="+n+",m="+m+",t="+t);
}
}