arithmeticexception.java

来自「一些相关的JAVA小实例」· Java 代码 · 共 24 行

JAVA
24
字号
class exceptionraised{
	protected exceptionraised(){
	}
	static int calculate(int operand1,int operand2){
		int result=operand1/operand2;
		return result;
	}
}
public class ArithmeticException{
protected ArithmeticException(){
	
}	
public static void main(String[] s){
	exceptionraised obj=new exceptionraised();
	try{
		int result =obj.calculate(9,0);
		System.out.println(result);
	}
	catch(Exception e){
		System.err.println("发生异常:"+e.toString());
		e.printStackTrace();
	}
}
}

⌨️ 快捷键说明

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