62,614
社区成员
发帖
与我相关
我的任务
分享
import java.io.*;
public class Test
{
public static void main(String[] args)
{
try
{
throwChecked(3);
throwRuntime(3); //感觉这条没执行,,,
}
catch (RuntimeException re)
{
System.out.println(re.getMessage());
}
catch(Exception e)
{
System.out.println(e.getMessage());
}
}
public static void throwChecked(int a) throws Exception
{
if (a > 0)
{
throw new Exception("ta > 0 ,exception");
}
}
public static void throwRuntime(int a)
{
if (a > 0)
{
throw new RuntimeException("re > 0,Runtime exception");
}
}
}