IntentService exception: java. lang. InstantiationException:, intentservice
public MyIntentService() {
super(nameStr);
}
JavalangInstantiationException in java reflection: exception, solved
The error KEY is used for instantiation, and the VALUE is used for instantiation.
String val = prop. getProperty (name );
ObjectPool. put (name, createObject (val ));
Common exceptions and solutions in java
1. java. lang. nullpointerexception
This exception is common. The exception is interpreted as "the program encounters a null pointer". 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 in wtk. The exception is interpreted as "the specified class does not exist ", here, we mainly consider whether the class name and path are correct. If the package is made under jb, the 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 "mathematical operation exception". For example, if an operation such as dividing by zero occurs 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 "array subscript out of bounds". Most of the programs now 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 "parameter errors of methods". Many methods in the j2s' class libraries 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 "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.
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:... the remaining full text>