1.3.3 改善后的异常处理
生活随笔
收集整理的這篇文章主要介紹了
1.3.3 改善后的异常处理
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
Demo:
import java.io.IOException; import java.net.ServerSocket;public class CoinTryCatch {public static void main(String[] args) {/** 本Demo有待優化得更合情合理且全面 **/try {// java.lang.ArithmeticException: / by zeroSystem.out.println(5/0);// IOServerSocket ss = new ServerSocket(8888);ss.close();// OutOfString[] sarr = new String[]{};System.out.println(sarr[0]);/** | **/} catch (IOException|ArrayIndexOutOfBoundsException e) {System.out.println("捕捉到IO或OutOf異常!");/** final Java 7 異常重拋——final關鍵字不是必須 **/} catch (final Exception e) {e.printStackTrace();}}}Ran As Java Application:
java.lang.ArithmeticException: / by zeroat cointest.CoinTryCatch.main(CoinTryCatch.java:13)?
轉載于:https://www.cnblogs.com/springup/p/5101929.html
總結
以上是生活随笔為你收集整理的1.3.3 改善后的异常处理的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 解决MWPhotoBrowser中的SD
- 下一篇: OC中对象拷贝概念