zoukankan      html  css  js  c++  java
  • 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
    }

    
    
  • 相关阅读:
    Leetcode:Convert Sorted List to Binary Search Tree
    Leetcode:Unique Binary Search Trees & Unique Binary Search Trees II
    Leetcode::Longest Common Prefix && Search for a Range
    Leetcode::Flatten Binary Tree to Linked List
    Leetcode::JumpGame
    leetcode power(x,n)
    Leetcode Letter Combinations of a Phone Number
    leetcode Reverse Nodes in k-Group
    leetcode Merge k Sorted Lists
    word ladder
  • 原文地址:https://www.cnblogs.com/naimao/p/13346524.html
Copyright © 2011-2022 走看看