As a game developer, programmers naturally have to be familiar with how to debug a program. and to debug the program, the natural need for the program's common anomalies have a certain understanding, these days many friends have raised a lot of questions, are about the game in the error, so here I will be some common procedures in the exception enumerated to everyone for reference:
1. Java.lang.NullPointerException
This exception you must all often encounter, the exception is explained is "the program encountered a null pointer", to put it simply is to invoke an uninitialized object or an object that does not exist, and this error often occurs in creating pictures, calling arrays, such as when the picture was uninitialized, or when the image was created with a path error, and so on. Null pointers appear in array operations, many of which are common mistakes made by friends who are just beginning to learn programming, which confuse initialization and array elements. The initialization of an array is the space needed to allocate the arrays, and the initialized array, the elements of which are not instantiated, are still empty, and therefore each element needs to be initialized (if it is to be invoked)
2. Java.lang.ClassNotFoundException
This anomaly is a lot of programmers who were originally developed in the development environment such as JB, put the package under the JB under the WTK to compile often problems, the exception is interpreted as "The specified class does not exist", where the main consideration of the class name and path is correct, if it is under the JB to do the package, Generally is the default plus package, so go to WTK after the package to pay attention to the path plus.
3. Java.lang.ArithmeticException
This exception is interpreted as "mathematical operation Anomaly", such as in the program divided by 0 of such an operation will be such an exception, for this anomaly, we will have a good check of their program involved in the mathematical operation of the place, the formula is not wrong.
4. Java.lang.ArrayIndexOutOfBoundsException
This anomaly is believed that many friends also often encountered, the exception is the explanation is "array subscript out of bounds", now most of the program has the operation of the array, so in the call to the arrays must be carefully checked to see their call subscript is not beyond the range of the array, generally speaking, The display (that is, directly using the constant current) is not too easy to make such a mistake, however, implicit (that is, variable representation of the subscript) calls are often wrong, there is a case, the program is defined in the length of the array is determined by some specific methods, not in advance, this time, it is best to first look at the length of the array, Lest this exception occur.
5. Java.lang.IllegalArgumentException
This exception is interpreted as "parameter error of method", and many J2ME methods in the class library can cause such errors in some cases, such as the volume parameter in the volume control method if written as a negative number, the exception, such as G.setcolor (int red,int green,int Blue) Three values in this method, if there are more than 255, this exception will also occur, so once this exception is found, we have to do is to quickly check the method call in the argument passed is not an error.
6. Java.lang.IllegalAccessException
This exception is interpreted as "no access", which occurs when the application calls a class, but the current method does not have access to the class. Be aware of this exception when using package in your program.
There are many other anomalies, I will not enumerate, I want to explain that, a qualified programmer, need to have a good understanding of the common problems in the program and the corresponding solution, otherwise just stay in the writing program without changing the program, will greatly affect their development. A full description of the exception can be found in the API.