Java Common exceptions

Source: Internet
Author: User
Tags integer division

1. java. Lang. nullpointerexception
This exception is often encountered by everyone. The exception is explained by & quot; the program encounters a null pointer & quot;. Simply put, it calls an uninitialized object or a non-existent object, this error often occurs when you create an image. When you call an array, the image is not initialized, or the path when the image is created is incorrect. There is a null pointer in array operations. In many cases, it is a common mistake for friends who are just learning programming, that is, to confuse array initialization with array element initialization. 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. java. Lang. classnotfoundexception
This exception is a problem that occurs frequently when many programmers originally developed in development environments such as JB compile the packages under JB under wtk. The exception is interpreted as & quot; the specified class does not exist & quot;. Here, we mainly consider whether the class name and path are correct. If the package is made under JB, package is usually added by default, therefore, add the package path after you go to wtk.
3. java. Lang. arithmeticexception
This exception is interpreted as a & quot; mathematical operation exception & quot;. For example, if an operation such as dividing by zero exists in a program, this exception occurs, we need to check whether the formula is inappropriate in the mathematical operations involved in our program.
4. java. Lang. arrayindexoutofboundsexception
This exception is often encountered by many friends. The exception is explained as & quot; array subscript out of bounds & quot;. Currently, most programs have Array Operations, therefore, when calling an array, you must carefully check whether the subscript you call exceeds the range of the array. In general, it is displayed (that is, the constant is used as the subscript directly) this is not easy to make calls, but implicit (that is, using variables to represent subscript) calls often encounter errors, the length of the array defined in the program is determined by some specific methods, not stated in advance. At this time, it is best to first check the length of the array to avoid this exception.
5. java. Lang. illegalargumentexception
This exception is interpreted as a & quot; method parameter error & quot;. Many methods in the j2s' class library may cause such errors in some situations, for example, if the volume parameter in the volume adjustment method is written as a negative number, this exception occurs, for example, 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 & quot; no access permission & quot;. 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.
There are still many other exceptions. I will not list them one by one. What I want to note is that a qualified programmer needs to have a good understanding of common problems in the program and corresponding solutions, otherwise, if you only write the program without modifying the program, it will greatly affect your development. For details about all exceptions, refer to the API.
Arithmetic exception class: arithmeticexecption
Null Pointer exception class: nullpointerexception
Type forced conversion exception: classcastexception
Array negative subscript exception: negativearrayexception
Array subscript out of bounds exception: arrayindexoutofboundsexception
Security violation exception: secturityexception
File ended exception: eofexception
File not found exception: filenotfoundexception
An error occurred while converting the string to a number: numberformatexception
Database Operation exception: sqlexception
Input and Output exceptions: ioexception
Method not found exception: nosuchmethodexception
Java. Lang. abstractmethoderror
Incorrect abstract method. Thrown when an application tries to call an abstract method.
Java. Lang. assertionerror
Assertion error. Used to indicate an assertion failure.
Java. Lang. classcircularityerror
Class loop dependency error. When initializing a class, if the cyclic dependency between classes is detected, this exception is thrown.
Java. Lang. classformaterror
Class format error. When the Java Virtual Machine attempts to read a Java class from a file and detects that the content of the file does not conform to the valid format of the class, it throws.
Java. Lang. Error
Error. Is the base class for all errors, used to identify serious program running problems. These problems usually describe abnormal situations that should not be captured by the application.
Java. Lang. exceptionininitializererror
Initialization program error. Thrown when an exception occurs during the execution of a class static initialization program. Static initialization programs are static statement segments directly included in the class.
Java. Lang. illegalaccesserror
Illegal access error. This exception is thrown when an application attempts to access, modify the field of a class, or call its method, but violates the visibility Declaration of the domain or method.
Java. Lang. incompatibleclasschangeerror
Incompatible class change error. This exception is thrown when the class definition on which the method being executed depends is incompatible. This error is easily caused when the Declaration definition of some classes in the application is modified without re-compiling the entire application.
Java. Lang. instantiationerror
Instantiation error. This exception is thrown when an application attempts to construct an abstract class or interface using the new operator of Java.
Java. Lang. internalerror
Internal error. Indicates that an internal error has occurred to the Java VM.
Java. Lang. linkageerror
Link 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 and does not recompile all the classes, in this case, an error occurs.
Java. Lang. noclassdeffounderror
Class Definition error not found. This error is thrown when the Java Virtual Machine or classloader tries to instantiate a class but cannot find the definition of the class.
Java. Lang. nosuchfielderror
Domain does not exist. This error is thrown when an application attempts to access or modify a certain domain without the definition of this domain.
Java. Lang. nosuchmethoderror
The method does not exist. This error is thrown when an application attempts to call a certain method without the definition of this method.
Java. Lang. outofmemoryerror
Memory insufficiency error. This error is thrown when the available memory is insufficient for the Java Virtual Machine to allocate to an object.
Java. Lang. stackoverflowerror
Stack overflow error. This error is thrown when the hierarchy of recursive calls of an application is too deep, resulting in 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 the Java Virtual Machine has encountered an unknown serious error.
Java. Lang. unsatisfiedlinkerror
A link error is returned. Thrown when the Java Virtual Machine does not find the native language definition of a class declared as the native method.
Java. Lang. unsupportedclassversionerror
Unsupported class version error. This error is thrown when the Java Virtual Machine attempts to read a class file but finds that the main and secondary versions of the file are not supported by the current Java virtual machine.
Java. Lang. verifyerror
Verification error. This error is thrown when the validators detect internal incompatibility or security issues in a class file.
Java. Lang. virtualmachineerror
Virtual Machine error. Indicates that the virtual machine is damaged or the resources required to continue the operation are insufficient.
Java. Lang. arithmeticexception
Arithmetic condition exception. For example, integer division by zero.

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.