Home >Java >javaTutorial >Explanation of Java classification exception issues
Error: error, usually does not require programmer management, generally refers to insufficient memory, etc.
Exception: exception
According to the timing of running, it is divided into:
Runtime exception: RuntimeException: Exception that only occurs when running.
Non-runtime exceptions:
According to whether they are safe or not, they are divided into:
Checked exceptions: file opening exceptions, file operation exceptions, database operation exceptions, etc.
Unchecked exceptions: programmers are not careful To verify, the resulting exceptions include subscript out-of-bounds exceptions, null pointer exceptions, and type conversion exceptions.
Processing methods:
Two methods: keyword processing such as try
throw and throws keyword processing
Principle: The lower layer should throw exceptions , the surface layer is converted into business language to remind users.
Exception handling in projects should be user-specific.
Business exception: Abnormality that occurs in the business.
Customized exception: encapsulates business exceptions as well as the location and cause of the exception.
Java Exception:
1、Error
2、Runtime Exception Runtime exception
3、Exception
4、throw user-defined exception
The exception class is divided into two types: the Error class represents compilation and system errors and does not allow capture; the Exception class represents exceptions triggered by standard Java library methods. The Exception class also contains two direct subclasses: Runtime_Exception and Non_RuntimeException.
The running exception class corresponds to compilation errors, which refers to various exceptions generated by the interpreter when a Java program is running. Running exceptions may appear anywhere and occur very frequently, so in order to avoid huge system resource overhead, the compiler does not check for exceptions. Therefore, runtime exceptions in the Java language may not necessarily be caught. Operation errors often indicate errors in the code, such as arithmetic exceptions (such as division by 0), subscript exceptions (such as array out-of-bounds), etc.
Non-running exceptions are instances of the Non_RuntimeException class and its subclasses, also known as detectable exceptions. The Java compiler uses the possible results in the analysis method or construction method to detect whether the Java program contains a handler for detecting exceptions. For each possible detectable exception, the throws clause of the method or construction method must list the exception corresponding the type. The exceptions defined in Java's standard packages java.lang java.util and java.net are non-running exceptions.
Arithmetic exception class: ArithmeticExecption
Null pointer exception class: NullPointerException
Type cast exception: ClassCastException
Array negative Standard exception: NegativeArrayException
Array subscript out-of-bounds exception: ArrayIndexOutOfBoundsException
Violation of security principles exception: SecurityException
File has ended Exception: EOFException
File not found Exception: FileNotFoundException
String to number conversion exception: NumberFormatException
Operation database exception: SQLException
Input and output exception: IOException
Method not found exception: NoSuchMethodException
java.lang.AbstractMethodError
Abstract method error. Thrown when the application attempts to call an abstract method.
java.lang.AssertionError
Assertion error. Used to indicate an assertion failure.
java.lang.ClassCircularityError
Class circular dependency error. When initializing a class, this exception is thrown if a circular dependency between classes is detected.
java.lang.ClassFormatError
Class format error. Thrown when the Java virtual machine attempts to read a Java class from a file and detects that the contents of the file do not conform to a valid format for the class.
java.lang.Error
Error. Is the base class for all errors and is used to identify serious program operation problems. These problems usually describe some unusual situation that should not be caught by the application.
java.lang.ExceptionInInitializerError
Initializer error. Thrown when an exception occurs during the execution of a class's static initializer. Static initializer refers to the static statement segment directly included in the class.
java.lang.IllegalAccessError
Illegal access error. This exception is thrown when an application attempts to access or modify a field of a class or call its method, but violates the visibility declaration of the field or method.
java.lang.IncompatibleClassChangeError
Incompatible class change error. This exception is thrown when an incompatible change occurs in the class definition on which the method being executed depends. Generally, this error is easily caused when the declaration definition of some classes in the application is modified without recompiling the entire application and then running it directly.
java.lang.InstantiationError
Instantiation error. This exception is thrown when an application attempts to construct an abstract class or interface through Java's new operator.
java.lang.InternalError
Internal error. Used to indicate that an internal error has occurred in the Java virtual machine.
java.lang.LinkageError
Linkage error. This error and all its subclasses indicate that a class depends on other classes. After the class is compiled, the dependent class changes its class definition without recompiling all classes, thus causing the error condition.
java.lang.NoClassDefFoundError
Class definition not found error. This error is thrown when the Java virtual machine or class loader attempts to instantiate a class and cannot find the definition of the class.
java.lang.NoSuchFieldError
Field does not exist error. This error is thrown when an application attempts to access or modify a field of a class that does not have a definition for that field.
java.lang.NoSuchMethodError
There is no error in the method. This error is thrown when the application attempts to call a method of a class that does not have a definition for the method.
java.lang.OutOfMemoryError
Out of memory error. This error is thrown when the available memory is insufficient for the Java virtual machine to allocate an object.
java.lang.StackOverflowError
Stack overflow error. This error is thrown when an application makes too many recursive calls and causes a stack overflow.
java.lang.ThreadDeath
The thread ends. This error is thrown when the stop method of the Thread class is called to indicate the end of the thread.
java.lang.UnknownError
Unknown error. Used to indicate that an unknown serious error has occurred in the Java virtual machine.
java.lang.UnsatisfiedLinkError
Unsatisfied link error. Thrown when the Java virtual machine does not find a native language definition of a class that declares a native method.
java.lang.UnsupportedClassVersionError
Unsupported class version error. This error is thrown when the Java virtual machine tries to read a certain class file, but finds that the major and minor version numbers of the file are not supported by the current Java virtual machine.
java.lang.VerifyError
Verification error. This error is thrown when the validator detects an internal incompatibility or security issue in a class file.
java.lang.VirtualMachineError
Virtual machine error. Used to indicate a situation where a virtual machine has been destroyed or has insufficient resources to continue operations.
java.lang.ArithmeticException
Arithmetic condition exception. For example: integer division by zero, etc.
java.lang.ArrayIndexOutOfBoundsException
Array index out-of-bounds exception. Thrown when the index into the array is negative or greater than or equal to the array size.
java.lang.ArrayStoreException
Array storage exception. Thrown when an object of non-array declared type is stored in an array.
java.lang.ClassCastException
Class cast exception. Suppose there are classes A and B (A is not the parent class or subclass of B), and O is an instance of A, then this exception is thrown when O is forced to be constructed as an instance of class B. This exception is often called a cast exception.
java.lang.ClassNotFoundException
Cannot find class exception. This exception is thrown when the application attempts to construct a class based on a class name in string form, but cannot find the class file with the corresponding name after traversing the CLASSPAH.
java.lang.CloneNotSupportedException
Clone exception is not supported. When the Cloneable interface is not implemented or the clone method is not supported, calling its clone() method will throw this exception.
java.lang.EnumConstantNotPresentException
There is no exception in the enumeration constant. This exception is thrown when an application attempts to access an enumeration object by name and enumeration type, but the enumeration object does not contain a constant.
java.lang.Exception
Root exception. Used to describe the situation the application wishes to capture.
java.lang.IllegalAccessException
Illegal access exception. This exception is thrown when the application attempts to create an instance of a class, access the class properties, or call the class method through reflection, and the definition of the class, attribute, method, or constructor cannot be accessed at that time.
java.lang.IllegalMonitorStateException
Illegal monitoring state exception. This exception is thrown when a thread attempts to wait for the monitor of an object (O) that it does not own or notifies other threads to wait for the monitor of the object (O).
java.lang.IllegalStateException
Illegal state exception. This exception is thrown when a method is called in the Java environment and application before it is in a legal calling state.
java.lang.IllegalThreadStateException
Illegal thread state exception. When the county is not in the legal calling state of a certain method and the method is called, an exception is thrown.
java.lang.IndexOutOfBoundsException
Index out-of-bounds exception. This exception is thrown when the index value of a sequence is less than 0 or greater than or equal to the sequence size.
java.lang.InstantiationException
Instantiation exception. This exception is thrown when trying to create an instance of a class through the newInstance() method, and the class is an abstract class or interface.
java.lang.InterruptedException
Interrupted exception. This exception is thrown when a thread is waiting, sleeping or otherwise suspended for a long time, and other threads terminate the thread through Thread's interrupt method.
java.lang.NegativeArraySizeException
The array size is a negative exception. This exception is thrown when an array is created with a negative size value.
java.lang.NoSuchFieldException
There is no exception in the property. This exception is thrown when accessing a non-existent property of a class.
java.lang.NoSuchMethodException
There is no exception in the method. This exception is thrown when accessing a non-existent method of a class.
java.lang.NullPointerException
Null pointer exception. This exception is thrown when the application attempts to use null where an object is required. For example: calling the instance method of the null object, accessing the properties of the null object, calculating the length of the null object, using the throw statement to throw null, etc.
java.lang.NumberFormatException
Number format exception. This exception is thrown when an attempt is made to convert a String to a specified numeric type and the string does not meet the format required by the numeric type.
java.lang.RuntimeException
Runtime exception. Is the parent class for all exceptions that can be thrown during normal operation of the Java virtual machine.
java.lang.SecurityException
Security exception. An exception thrown by the security manager to indicate a security violation.
java.lang.StringIndexOutOfBoundsException
String index out-of-bounds exception. This exception is thrown when a character in a string is accessed using an index value that is less than 0 or greater than or equal to the sequence size.
java.lang.TypeNotPresentException
The type does not exist. This exception is thrown when an application attempts to access a type as a string representation of the type name, but the type cannot be found based on the given name. The difference between this exception and ClassNotFoundException is that this exception is an unchecked (unchecked) exception, while ClassNotFoundException is a checked (checked) exception.
java.lang.UnsupportedOperationException
Unsupported method exception. Exception indicating that the requested method is not supported.
Exception
javax.servlet.jsp.JspException: Cannot retrieve mapping for action /Login (/Login is your action name)
Possible reasons The above is the detailed content of Explanation of Java classification exception issues. For more information, please follow other related articles on the PHP Chinese website!
action no longer struts- defined in config.xml, or no matching action is found, for example, use