📄 trycatchfinally.java
字号:
public class TryCatchFinally{
static void Proc( int sel ){
System.out.println("----- In Situation"+sel+" -----");
try{
if( sel==0 ){
System.out.println("no Exception caught");
return;
}else if( sel==1 ){
int i=0;
int j=4/i;
}else if( sel==2 ){
int iArray[]=new int[4];
iArray[10]=3;
}
}catch( ArithmeticException e ){
System.out.println("Catch "+e);
}catch( ArrayIndexOutOfBoundsException e ){
System.out.println("Catch "+e.getMessage());
}catch( Exception e ){
System.out.println("Will not be executed");
}finally{
System.out.println("in Proc finally");
}
}
public static void main( String args[] ){
Proc( 0 );
Proc( 1 );
Proc( 2 );
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -