例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);
? }
?}
?
?
轉載于:https://www.cnblogs.com/zhangxinbo/archive/2013/04/25/3043552.html
總結
以上是生活随笔為你收集整理的例5-17和例5-18的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 备份文件命令SqlServer一键复制数
- 下一篇: 漂亮的页面向导和Tab插件(Jquery