第一次修改,catch 里我写的是IOException类型,编译运行后,IDE 抛出以下异常我才知道构造catch时类型是 NumberFormatException。怎么才能在不编译运行时就知道要 catch哪些类型的异常呢?
IOException
NumberFormatException
Exception in thread "main" java.lang.NumberFormatException: For input string: "x9"
相同问题的同学请看下一章。
Ctrl+鼠标左键 点击 需要检查异常的方法,里面会有类似于 throws NumberFormatException 可以知道他会抛出NumberFormatException异常
看源码,或者直接exception
Sign in to make a reply
余杰爱生活y
第一次修改,catch 里我写的是
IOException
类型,编译运行后,IDE 抛出以下异常我才知道构造catch时类型是NumberFormatException
。怎么才能在不编译运行时就知道要 catch哪些类型的异常呢?Exception in thread "main" java.lang.NumberFormatException: For input string: "x9"