Java -- RuntimeException (runtime exception), runtimeexception exception

Source: Internet
Author: User

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

 

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.