Tag: null ERR Cannot find run programming error number throws exception no numbers
Abnormal
Exceptions that occur during Java operation can be divided into two categories:
1. Error: JVM system internal error, resource consumption and other serious situation
2. Exceptions (Exception): Other general issues caused by programming errors or accidental external factors
- You can throw exceptions in the method definition for the following scenarios
(1) A method that throws a "checked exception" is called in the method
(2) An error occurred while the program was running and a "checked exception" was thrown with the throw clause
A. Open square root to negative numbers
b. Null pointer access
C. Attempting to read a file that does not exist
D. Network connection interrupted
E. Denominator is 0
PS: Do not throw: those exceptions derived from the error
Java Exception handling mechanism
- When an exception occurs during the execution of a Java program, an exception class object is automatically generated, which is referred to the Java Runtime System, which is called throw (throw) exception----active
- When the Java runtime system receives an exception object, it looks for code that can handle the exception and hands the current exception object to its processing, a process known as catch (catch) exception----passive
- If the Java runtime system cannot find a way to catch an exception, the runtime system terminates and the corresponding Java program exits
- Programmers usually only deal with exception, and can do nothing about error errors
Common exceptions:
- RuntimeException
- ArithmeticException: Mathematical calculation anomalies
- NullPointerException: null pointer exception
- Negativearraysizeexception: Negative group length exception
- ArrayIndexOutOfBoundsException: Array index out-of-bounds exception
- ClassNotFoundException: Class file not found exception
- ClassCastException: Abnormal shape
- IOException
- FileNotFoundException: File not found exception
- Eofexception: Read-write file tail exception
- Malformedurlexception:url Format Error exception
- Socketexception:socket Exception (socket)
- Arithmetic Exception class: ArithmeticException
- Null pointer exception class: NullPointerException
- Type cast Exception: ClassCastException
- Array negative subscript exception: Negativearrayexception
- Array subscript out-of-bounds exception: ArrayIndexOutOfBoundsException
- Violation of security principle exception: Secturity Exception
- File ended exception: Eofexception
- File not found exception: FileNotFoundException
- string conversion to numeric exception: NumberFormatException
- Manipulating Database Exceptions: SQLException
- Input/Output exception: IOException
- Method not found exception: Notsuchmethodexception
- Abstract method Error Exception Java.lang.AbstractMethodError
- Assertion Error Exception Java.lang.AssertionError
- Class Loop dependency Error Exception Java.lang.ClassCircularityError
- PS: When an exception is not processed in the current try-catch, it will be thrown to the method that called it (throws)
- PS: When an exception has not been able to be processed and then returned to the main method, the program will stop running
If the program requires information about the exception object to be accessed in the catch block, it can be obtained by calling the method of the exception parameter after the catch. When the Java runtime decides to call a catch block to handle the exception object, the exception object is assigned to the exception parameter after the catch block, and the program can obtain information about the exception by this parameter.
GetMessage (): Returns the detailed description string for the exception
Printstacktrace (): The error stack information for the exception is output on the screen
Printstacktrace (PrintStream s): Outputs the trace stack information for this exception to the specified output stream
Getstackreace (): Returns the trace stack information for this exception
Exception (Exception)