somecatch_2.java

来自「软通公司培训的课件和习题里面有答案。。。」· Java 代码 · 共 36 行

JAVA
36
字号
package com.servern.java;



public class SomeCatch_2 {
	
	int i = 5 ;
	int j = 0 ;
	
	private double  devide(int a ,int b){
		return a/b ;
	}

	public static void main(String []args){
		SomeCatch_2 s = new SomeCatch_2();
	   	  try
	   	  {
			double result = s.devide(s.i, s.j);
			System.out.println("the result is " + result);
	   	  }
	   	  catch (ArithmeticException e)
	   	  {
	   	  	 System.out.println("the program is running into ArithmeticException");
	   	  	 System.out.println(e.getMessage());
	   	  }
	   	  catch (Exception e)
	   	  {
	   	  	System.out.println("the program is running into other unknowed Exception");
	   	  	System.out.println(e.getMessage());
	   	  }
	   	  
	   	  System.out.println("the program is running here, that is normal!");
	   }

}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?