11.8RuntimeException

The maximum feature of this class exception: the program at compile time the user is not a mandatory requirement exception processing, the user can selectively processed according to their needs.
If you want to change the string data type int, then the Integer class can be used for processing because the Integer class defines the following methods.
String conversion int: public static int the parseInt (String S) throws a NumberFormatException.
At this time parseInt () method throws an NumberFormatException, and this exception class belongs to a subclass of RuntimeException.
NumberFormatException inheritance structure

java.lang.Object
   |- java.lang.Throwable
      |- java.lang.Exception
         |- java.lang.RuntimeException  		→ 		运行时异常
            |- java.lang.IllegalArgumentException
               |- java.lang.NumberFormatException
public class JavaDemo {
	public static void main(String args[]) {
		int num = Integer.parseInt("123");// 字符串转数字
		System.out.println(num);// 输出转换结果
	}
}

RuntimeException and Except the difference?
Except RuntimeException is a subclass.
Except defines the exception must be handled, and may be selectively RuntimeException defined exception handling.

Published 161 original articles · won praise 9 · views 3080

Guess you like

Origin blog.csdn.net/ll_j_21/article/details/104748834