測試代碼, java.lang.ArrayIndexOutOfBoundsException沒有被catch。沒有catch的Exception,會致使VM中止。 AndroidRuntime: Caused by: java.lang.ArrayIndexOutOfBoundsException: length=20; index=30java
<!-- lang: java -->測試
<!-- lang: java --> int testexcepiton(int i) throws IOException{ Log.v(TAG, "testexcepiton i="+i); if(i == 100){ throw new IOException("Haha here"); } return 1; } try{ int []hh = new int[20]; hh[30] = 01; Log.v(TAG, "hh[0]="+hh[0]); testexcepiton(1); } catch(IOException e){ Log.v(TAG, "e="+e); } finally{ Log.v(TAG, "@@@finnaly in try"); } Log.v(TAG, "@@@after try catch");