import java.util.Scanner;
public class Test
{
static class MyException extends RuntimeException
{
public MyException()
{
super();
}
public MyException(String s)
{
super(s);
}
}
public static void cal(int a,int b)
{
try
{
int c=a/b;
}
catch (MyException e)
{
e.printStackTrace();
}
}
public static void main(String[]args)
{
int a,b;
System.out.println("please input a and b.");
Scanner scanner=new Scanner(System.in);
a=scanner.nextInt();
b=scanner.nextInt();
cal(a,b);
}
}
自定义运行时异常
最新推荐文章于 2023-08-14 10:47:53 发布