Common Java Exceptions

Source: Internet
Author: User
Tags arithmetic class definition instance method throw exception unsupported

in the Some exceptions are provided in Java to describe frequently occurring errors, some of which require a programmer to capture or declare, and some are automatically captured by a Java virtual machine. Common exception classes in Java are shown in the following table:

Exception class

Description

ClassCastException

Type conversion Exception class

ClassNotFoundException

The corresponding class was not found

ArithmeticException

Arithmetic exceptions

ArrayIndexOutOfBoundsException

Array subscript out of bounds exception

Arraystoreexception

An exception is thrown when an array contains incompatible values

SQLException

Manipulating Database Exceptions

NullPointerException

Null pointer exception

Nosuchfieldexception

Field not found exception

Nosuchmethodexception

Method did not find the thrown exception

NumberFormatException

The string is converted to a number thrown by the exception

Negativearraysizeexception

The exception that is thrown when the number of array elements is negative

Stringindexoutofboundsexception

String index out of range throw exception

IOException

Input/Output exception

Illegalaccessexception

Do not allow access to a class

Instantiationexception

An exception that is thrown when an application attempts to create an instance of a class using the newinstance () method in class classes , and the specified class object cannot be instantiated

Eofexception

File has ended exception

FileNotFoundException

File not found exception

arithmetic Exception class:Arithmeticexecption
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:secturityexception
file has ended exception:eofexception
File not found exception:FileNotFoundException
the string is converted to a numeric exception:NumberFormatException
To manipulate database exceptions:SQLException
input and Output exceptions:IOException
method did not find an exception:nosuchmethodexception
Java.lang.AbstractMethodError
Abstract method Error. Thrown when an application tries to invoke an abstract method.
Java.lang.AssertionError
assertion is wrong. Used to indicate a condition in which an assertion failed.
Java.lang.ClassCircularityError
class loop-dependent error. When a class is initialized, the exception is thrown if a circular dependency between the classes is detected.
Java.lang.ClassFormatError
The class format is incorrect. WhenJavaThe virtual machine tries to read from a fileJavaclass, while detecting that the contents of the file do not conform to the valid format of the class.
Java.lang.Error
error. is the base class for all errors that identify serious program run issues. These problems often describe anomalies that should not be captured by the application.
Java.lang.ExceptionInInitializerError
Initialization program error. Thrown when an exception occurs during the execution of a static initializer for a class. Static initializers are those that are included directly in the class.Staticstatement segment.
Java.lang.IllegalAccessError
illegal access error. When an app tries to access and modify a class's Domain (Field) or call its method, but violate the visibility declaration of the domain or method, throws the exception.
Java.lang.IncompatibleClassChangeError
incompatible class change error. This exception is thrown when an incompatible change is made to the class definition on which the method being executed depends. This error is easily thrown when you modify the declaration definition for some classes in your app without recompiling the entire application.
Java.lang.InstantiationError
instantiation of the error. When an application tries to passJavaof theNewoperator constructs an abstract class or interface when the exception is thrown.
Java.lang.InternalError
internal error. Used to indicateJavaAn internal error occurred on the virtual machine.
Java.lang.LinkageError
link error. The error and all its subclasses indicate that a class depends on another class, and after that class is compiled, the dependent class changes its class definition without recompiling all of the classes, which in turn raises the error condition.
Java.lang.NoClassDefFoundError
class definition error not found. WhenJavathe virtual machine or the class loader attempted to instantiate a class, and the error was thrown when the definition of the class was not found.
Java.lang.NoSuchFieldError
There are no errors in the domain. This error is thrown when an application attempts to access or modify a domain of a class that does not have a definition of that domain in the definition of that class.
Java.lang.NoSuchMethodError
method has no errors. This error is thrown when an application attempts to invoke a method of a class that does not have the definition of the method in the definition of the class.
Java.lang.OutOfMemoryError
Insufficient memory error. When available memory is not enough to allowJavaThis error is thrown when the virtual machine is assigned to an object.
Java.lang.StackOverflowError
Stack Overflow error. This error is thrown when the hierarchy of an application recursive call is too deep to cause a stack overflow.
Java.lang.ThreadDeath
The thread ends. When callingThreadClass ofStopmethod is used to indicate the end of the thread.
Java.lang.UnknownError
unknown error. Used to indicateJavaa situation in which the virtual machine has an unknown critical error.
Java.lang.UnsatisfiedLinkError
an unsatisfied link error. WhenJavathe virtual machine does not find a class declared asnativemethod is thrown when the native language definition of the
Java.lang.UnsupportedClassVersionError
Unsupported class version error. WhenJavaThe virtual machine tries to read from a class file, but discovers that the main and minor version number of the file is not currentlyJavaThis error is thrown when the virtual machine is supported.
Java.lang.VerifyError
validation 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. A condition that indicates that the virtual machine is compromised or that the resource required to continue performing the operation is insufficient.
Java.lang.ArithmeticException
arithmetic condition exception. For example: integers except 0.
Java.lang.ArrayIndexOutOfBoundsException
array index out-of-bounds exception. Thrown when the index value of an array is negative or greater than or equal to the size of the arrays.
Java.lang.ArrayStoreException
array Storage exception. Thrown when a non-array declaration type object is placed into the array.
Java.lang.ClassCastException
class shape exception. Suppose there are classesAand theB(Ais notBparent class or subclass),Ois aAinstance, then when forcing theOconstruct as ClassBthe exception is thrown when an instance of the This exception is often called coercion type conversion exception.
Java.lang.ClassNotFoundException
The class exception could not be found. When an application attempts to construct a class based on the class name as a string, while traversingClasspahthe corresponding name cannot be found after theclassfile, the exception is thrown.
Java.lang.CloneNotSupportedException
cloning exceptions are not supported. When not implementedcloneableinterface or does not support cloning methods,call itsClone ()method throws the exception.
Java.lang.EnumConstantNotPresentException
An enumeration constant does not have an exception. 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
The root exception. Used to describe what the application wants to capture.
Java.lang.IllegalAccessException
an illegal access exception. This exception is thrown when an application attempts to create an instance of a class by reflection, accesses the class property, calls the class method, and then cannot access the definition of a class, property, method, or constructor method.
Java.lang.IllegalMonitorStateException
violations of the monitoring State anomalies. When a thread tries to wait for an object that it does not own (O) or notifies other threads to wait for the object (O), the exception is thrown when the monitor is
Java.lang.IllegalStateException
an abnormal state of law. When inJavathe environment and the application are not yet in the legal invocation state of a method, and the exception is thrown when the method is called.
Java.lang.IllegalThreadStateException
an illegal thread state exception. An exception is thrown when the county seat is not in the legal calling state of a method and the method is called.
Java.lang.IndexOutOfBoundsException
index out-of-bounds exception. When accessing a sequence, the index value is less than0or greater than or equal to the sequence size, the exception is thrown.
Java.lang.InstantiationException
instantiate the exception. When trying to passnewinstance ()method to create an instance of a class that is an abstract class or interface that throws the exception.
Java.lang.InterruptedException
aborted exception. When a thread is in a long wait, hibernate, or other paused state, the other threadsThreadof theInterruptthe exception is thrown when the thread is terminated by a method.
Java.lang.NegativeArraySizeException
the array size is a negative value exception. This exception is thrown when an array is created with a negative size value.
Java.lang.NoSuchFieldException
no exception exists for the property. This exception is thrown when a property that does not exist for a class is accessed.
Java.lang.NoSuchMethodException
method has no exception. This exception is thrown when a non-existent method of a class is accessed.
Java.lang.NullPointerException
NULL pointer exception. When an application tries to use an object where it is requiredNULL, the exception is thrown. For example: CallNULLAn instance method of an object, AccessNULLobject's properties, calculationNULLlength of the object, useThrowstatement throwsNULLand so on.
Java.lang.NumberFormatException
number format exception. When trying to put aStringthe exception is thrown when the specified numeric type is converted to a format that does not meet the requirements of the number type.
Java.lang.RuntimeException
run-time exception. Is allJavathe parent class of the exception that can be thrown during normal operation of the virtual machine.
Java.lang.SecurityException
security Exception. Thrown by the security manager to indicate an exception that violates the security situation.
Java.lang.StringIndexOutOfBoundsException
string index out of bounds exception. When you use an index value to access a character in a string, the index value is less than0or greater than or equal to the sequence size, the exception is thrown.
Java.lang.TypeNotPresentException
there is no exception for type. The exception is thrown when an app tries to access the type as a string representation of a type name, but the type is not found according to the given name. This exception is associated withclassnotfoundexceptionThe difference is that the exception isunchecked(not checked) exception, andclassnotfoundexceptionis achecked(checked) exception.
Java.lang.UnsupportedOperationException
Unsupported method exception. An exception that indicates that the requested method is not supported.
Exception
Javax.servlet.jsp.JspException:Cannot Retrieve mapping for Action/login(/loginit's yours.Actionname)
Possible causes
ActionNo MoreStruts-config.xmlor no match is found in theAction, such as inJSPused in Files 

Common Java Exceptions

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.