📄 exception5.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 + -