日期:2014-05-20  浏览次数:20727 次

method的exception与方法内exception的区别
public void print(String phrase, int max){
if (phrase == null || max < 0){
throw new IllegalArgumentException("String is null, or max is smaller than 0");
}
}
上面的这个是一个普通的throw new IllegalArgumentException
==========================================================================

  public static void main(String[] args) throws FileNotFoundException
这个是定义在method这一行的。
=========================================================================

请问这两者有什么区别?定义method这一行的Exception看起来没有什么实质性作用。

------解决方案--------------------
异常机制及throw与throws的区别
------解决方案--------------------
简单说
throw 是你自己抛出异常
throws 是说方法可能抛出异常