日期:2014-05-20 浏览次数:21037 次
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");
        }
    }
}