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
}


posted @ 2020-07-20 18:13  发哥讲Java  阅读(232)  评论(0编辑  收藏  举报