public class RuntimeExceptionDemo01 {   
public static void main(String[] args) {    
    String string="123";    
    int temp=Integer.parseInt(string);    
    System.out.println("123*123=: "+temp*temp);    
}    
}
    public static int parseInt(String s) throws NumberFormatException {    
    return parseInt(s,10);    
    }
为什么main里不需要try catch?:
NumberFormatException extends IllegalArgumentException
IllegalArgumentException extends RuntimeException
RuntimeException extends Exception
可知:
1,Exception在程序中必须使用try。。。catch进行处理。
2,RuntimeException可以不使用try。。。catch进行处理,但如果有异常产生,则异常交由JVM进行处理。
Exception和RuntimeException,布布扣,bubuko.com
原文:http://www.cnblogs.com/vonk/p/3891674.html