• 13、Java 异常处理


    1

    退JavaJava

    Javathrow JavaJRE

    2

    Javatrycatchfinallythrowthrows

    3

    IOException
    ArithmeticExecption
    NullPointerException
    ClassCastException
    SQLException
    FileNotFoundException
    NegativeArrayException
    ArrayIndexOutOfBoundsException
    SecturityException
    EOFException
    NumberFormatException
    NoSuchMethodException

    4

    4.1trycatch
    try{

       // 

      }catch(ExceptionName e1){

       //Catch 

    }
    4.2throws

    使throws使throws

    4.3throw

    throwtry

    4.4

    tryfinallyfinallytry使

    使finally

    finally {
       // Code for finally block
    }

    5

    Java Exceptionchecked exceptionRuntimeException

    StringStringThrowableThrowable

    package java.io;

    public class IOException extends Exception {
       static final long serialVersionUID = 7818375828146090155L;

       public IOException() {
    super();
      }

       public IOException(String message) {
    super(message);
      }

       public IOException(String message, Throwable cause) {
           super(message, cause);
      }

       public IOException(Throwable cause) {
           super(cause);
      }
    }

    6

    使

    try {
       // May throw Exception1, Exception2, or Exception3
    }
    catch (Exception1 | Exception2 | Throwable    e) {
       // Handle Exceptions here
    }

    
    
  • 相关阅读:
    求10个随机数的最大值、最小值、和、平均值
    设计并编写代码自动格斗类游戏
    用while实现阶乘
    安卓第三次作业
    第二次作业
    第一次作业
    第四次作业
    dialog
    用画图的方法理解原型对象和原型链,事半功倍今晚不加班
    【学习笔记】浅析Promise函数
  • 原文地址:https://www.cnblogs.com/naimao/p/13346524.html
Copyright © 2020-2023  润新知