-
Java.lang.NullPointerException
This exception everyone must often encounter, the exception of the explanation is "the program encountered a null pointer", simply called an uninitialized object or non-existent object, this error often occurs in the creation of images, call array of these operations, than the slice is not initialized, or the image is created by the path error and so on. A null pointer appears in an array operation, and in many cases is a common mistake made by friends who are just beginning to learn programming, which confuses the initialization of arrays and the initialization of the array elements. The initialization of an array is the space required for the allocation of arrays, and the initialized array, where the elements are not instantiated, are still empty, so you also need to initialize each element (if it is to be called).
2. Java.lang.ClassNotFoundException
This anomaly is a lot of developers originally developed in the development environment such as JB, put JB under the package under the WTK to compile frequently problems, the explanation of the exception is "The specified class does not exist", here the main consideration is the name and path of the class is correct, if it is in JB under the package, Generally is the default plus the package, so go to the WTK to pay attention to add the package path.
3. Java.lang.ArithmeticException
The explanation of this anomaly is "mathematical operation Anomaly", for example, the program appears divided by 0 such an operation will be such an exception, for this anomaly, we will have to check the application of their own procedures involved in the mathematical operation of the place, the formula is not inappropriate.
4. Java.lang.ArrayIndexOutOfBoundsException
This exception is believed many friends also often encountered, abnormal explanation is "array subscript out of bounds", now most of the program has an array of operations, so in the call arrays must be carefully checked, to see if their call subscript is not beyond the scope of the array, in general, The display (that is, directly with the constant subscript) call is not easy to make such a mistake, but the implicit (that is, the use of variable-subscript) calls are often wrong, there is also a case, the length of the defined array in the program is determined by certain methods, is not declared beforehand, it is better to look at the array length, To prevent this exception from occurring.
5. Java.lang.IllegalAccessException
This exception is interpreted as "no access", which occurs when the application is calling a class, but the current method does not have access to the class. You should pay attention to this exception in cases where the package is used in the program.
5 common exceptions in Java (Exception)