Java -- RuntimeException (runtime exception), runtimeexception exception
[Reprinted from]: http://blog.csdn.net/qq7342272/article/details/7940741
Java runtime exceptions may be thrown when the java Virtual Machine is working normally.
Java provides two exception mechanisms. One is RuntimeExepction and the other is checked execption ).
Checktype exception: IO and SQL exceptions that we often encounter are checktype exceptions. For such exceptions, the java compiler requires that we must catch these exceptions. Therefore, whether we are willing or not, we can only write a bunch of catch statements to catch these exceptions.
Runtime exception: we can leave it empty. When such an exception occurs, it is always taken over by the virtual machine. For example, we have never handled NullPointerException, which is a runtime exception, and this exception is one of the most common exceptions.
RuntimeExecption is under the java. lang package,
The following is a running exception provided by the Java Virtual Machine.
AnnotationTypeMismatchException,
ArithmeticException,
ArrayStoreException,
BufferOverflowException,
BufferUnderflowException,
CannotRedoException,
CannotUndoException,
ClassCastException,
Cmcmexception,
ConcurrentModificationException,
DOMException,
EmptyStackException,
EnumConstantNotPresentException,
EventException,
IllegalArgumentException,
IllegalMonitorStateException,
IllegalPathStateException,
IllegalStateException,
ImagingOpException,
IncompleteAnnotationException,
IndexOutOfBoundsException,
JMRuntimeException,
LSException,
MalformedParameterizedTypeException,
MirroredTypeException,
MirroredTypesException,
MissingResourceException,
NegativeArraySizeException,
NoSuchElementException,
Nosuchmachismexception,
NullPointerException,
ProfileDataException,
ProviderException,
RasterFormatException,
RejectedExecutionException,
SecurityException,
SystemException,
TypeConstraintException,
TypeNotPresentException,
UndeclaredThrowableException,
UnknownAnnotationValueException,
UnknownElementException,
UnknownTypeException,
UnmodifiableSetException,
UnsupportedOperationException,
WebServiceException
Seeing so many exceptions, it is very easy to find out the common 5 runtime exceptions.
Example: ClassCastException (class conversion exception)
IndexOutOfBoundsException (array out-of-bounds)
NullPointerException (NULL pointer)
ArrayStoreException (Data Storage exception, inconsistent types when operating arrays)
BufferOverflowException exception for IO operations