zoukankan      html  css  js  c++  java
  • Exception和RuntimeException

    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进行处理。

  • 相关阅读:
    走迷宫(三):在XX限制条件下,是否走得出。
    ELMo
    BERT
    ARNOR 远程关系监督抽取
    谷歌T5
    seq2seq
    Attention Is All You Need(Transformer)
    attention的实现
    RNN
    test
  • 原文地址:https://www.cnblogs.com/vonk/p/3891674.html
Copyright © 2011-2022 走看看