Common runtime exception

Source: Internet
Author: User

 

Arithmeticexception (exception with a division of 0), bufferoverflowexception (buffer overflow exception), bufferunderflowexception (buffer overflow exception), indexoutofboundsexception (outbound exception ),Nullpointerexception(NULL pointer exception), Emptystackexception (empty stack exception), illegalargumentexception (invalid parameter exception), negativearraysizeexception, nosuchelementexception, securityexception, systemexception, undeclaredthrowableexception

1. java. Lang. nullpointerexception
The exception is interpreted as "the program encounters a null pointer". In short, it calls an uninitialized object or a non-existent object, that is, the array initialization and array element initialization are confused. Array initialization allocates the required space to the array. The elements in the initialized array are not instantiated and are still empty, therefore, you also need to initialize each element (if you want to call it)
2. The exception of Java. Lang. classnotfoundexception is interpreted as "the specified class does not exist ".
3. The exception of Java. Lang. arithmeticexception is interpreted as a "mathematical operation exception". For example, if a division by zero operation occurs in a program, this exception occurs.
4. java. Lang. arrayindexoutofboundsexception
The exception is interpreted as "array subscript out of bounds". Currently, most programs operate on arrays. Therefore, you must check the array carefully when calling the array, check whether the subscript you call is beyond the range of the array. In general, it is not easy to make such an error when calling (that is, directly using a constant as a subscript), but it is implicit (that is, using a variable to represent the subscript) an error occurs frequently when a call is made. In another case, the length of the array defined in the program is determined by some specific methods rather than stated in advance. At this time, check the length of the array to avoid this exception.
5. java. Lang. illegalargumentexception
This exception is interpreted as "method parameter error", such as G. setcolor (INT red, int green, int blue) three values in this method, if there is more than 255, this exception will also occur, so once this exception is found, what we need to do, check whether the parameter passing in the method call is incorrect.
6. java. Lang. illegalaccessexception
This exception is interpreted as "no access permission". This exception occurs when the application calls a class but the current method does not have access permission for this class. Pay attention to this exception when package is used in the program.

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.