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

📄 exception5.java

📁 课本异常处理实例。各种异常处理
💻 JAVA
字号:
//自定义异常
class OverFlowException extends Exception
{
	OverFlowException()
	{
		System.out.println("此处数据有溢出,溢出类是OverFlowException");
	}
}

public class Exception5
{
	public static int x=100000;
	public static int multi() throws OverFlowException
	{
		int aim;
		aim=x*x*x;
		if(aim>2.15E9 || aim<0)
			throw new OverFlowException();
		else
			return x*x*x;
	}
	public static void main(String args[])
	{
		int y;
		try
		{
			y= multi();
			System.out.println("y="+y);
		}
		catch(OverFlowException e)
		{
			System.out.println(e);
		}
	}
}

⌨️ 快捷键说明

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