⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 excephandling.java

📁 Java异常
💻 JAVA
字号:
import java.io.*;
	
public class ExcepHandling{	
static float c;	
	public static  void main(String Args[]){
	BufferedReader readin=new BufferedReader(new InputStreamReader(System.in));	
	try{
	System.out.println("请输入数字字符串1:");	
	String  input1=readin.readLine();//穦玻ネIOException
	float a=Float.parseFloat(input1);//穦玻ネNumberFormatException
	System.out.println("请输入数字字符串2");
	String  input2=readin.readLine();//穦玻ネIOException	
	float b=Float.parseFloat(input2);//穦玻ネNumberFormatException
		
	c=division(a,b);		
	
	}catch(IOException ioe){
		System.out.println("IO异常");
		System.out.println(ioe.getMessage());
		System.out.println("这里是输入输出异常");
		System.exit(0);
	}catch(NumberFormatException nfe){
		System.out.println("数字格式异常");
		System.out.println(nfe.getMessage());
		System.out.println("这里是数字格式异常");		
		System.exit(0);
	}catch(ArithmeticException ae){
		System.out.println(ae.getMessage());
		System.exit(0);
	}finally{
		System.out.println("啊啊啊啊啊啊啊啊啊啊阿"+'\n'+c);
		System.exit(0);
	}
	}
	
	static float division(float arg1,float arg2)throws ArithmeticException{
		if(arg2==0) throw new ArithmeticException("算术异常");
		float result;
		result=arg1/arg2;
		return result;
	}
			
			
	

}

⌨️ 快捷键说明

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