try--catch--finally格式:
try{
}catch(错误类型){
}finally{
}
执行情况:
package javatest5;
public class test {
public static void main(String[] args) {
int num1=15;
int num2=0;
try{
System.out.println("商等于:"+num1/num2);
}catch(Exception ex){
System.out.println("程序出现错误");
}finally{
System.out.println("无论程序错不错,我finally会一直运行的");
}
}
}