Java exception-18 days study notes

Error

Error class objects are generated and thrown by the Java virtual machine. Most errors have nothing to do with the operations performed by the code writer.

  • Java virtual machine operation error (Virtual MachineError), when the JVM no longer has the memory resources needed to continue the operation, an OutOfMemoryError will appear. When these exceptions occur, the Java Virtual Machine (JVM)-generally chooses the thread to terminate;

  • There are also class definition errors (NoClassDefFoundError) and link errors (LinkageError) that occur when the virtual machine tries to execute the application. These errors are uncheckable because they are outside the control and processing power of the application, and most of them are conditions that are not allowed to occur during the program's operation.

Exception

  • There is an important subclass RuntimeException in the Exception branch (runtime exception)

  • ArrayIndexOutOfBoundsException (array index out of bounds)

  • NullPointerException (Null PointerException)

  • ArithmeticException (arithmetic exception)

  • MissingResourceException (missing resource)

  • ClassNotFoundException (class not found) and other exceptions, these exceptions are not checked exceptions, the program can choose to capture and handle, or not to handle.

  • These exceptions are generally caused by program logic errors, and the program should avoid such exceptions from a logical perspective as much as possible;

  • The difference between Error and Exception: Error is usually a catastrophic fatal error that cannot be controlled and handled by the program. When these exceptions occur, the Java Virtual Machine (JVM) generally chooses to terminate the thread; Exception can usually be programmed Deal with these exceptions as much as possible in the program.

Guess you like

Origin blog.csdn.net/yibai_/article/details/114993303