1. When using the println() method for an object of String type, if the object is null, null will be printed instead of triggering NullPointerException. The problem cited here is that it is easy to cause misunderstandings and may cause problems for future operations on strings.
2. NullPointerException is thrown. The main reason is that the existence of the object is not verified. It often occurs in jsp programming: if (request.getParameter("username").equals("xxx")), out.println(session. getAttribute("record")) etc. The way to solve this problem is to perform a null comparison before use: if (request.getParameter(“username”)!=null) {if if (request.getParameter(“username”).equals(“xxx”))…} .
3. NumberFormatException is thrown: The main reason is that the user inputs other illegal characters when converting the content submitted by the user into an integer or floating point number. The main way to deal with it is to use try/catch blocks where conversion is required to catch this exception and then prompt the user to enter legal data.
4. StringIndexOutOfBoundsException exception is thrown: The main reason is that using String's substring(), charAt() and other methods, and the length of the string is not enough, this exception will be thrown; NullPointerException will also be thrown when the string is null. The solution is to determine the null value, determine the length or convert it to a byte array. Considering that there are many operations, they can be encapsulated into javabeans.
5. NoClassDefFoundError is triggered. The main reason is that the class path or class file is placed incorrectly. The placement of class files must meet the requirements of the server.
6. The java.lang.Error error is caused. The main reason is that the external resources accessed by the system are not closed, resulting in a large amount of waste of external resources, which may eventually cause the system to fail to operate normally; the external resources accessed by the system are closed too many times. , the external system cannot handle it normally; the external resources accessed by the system are abnormal. The solution is: before accessing external resources, first check whether the resource (such as a database) can be connected or operated normally; when accessing external resources, if a connection is made, be sure to perform a shutdown operation and perform only one shutdown operation; try to do so in the same External resources are shared during operations to reduce the resource consumption of the operation and improve program execution efficiency.
http://blog.csdn.net/kiss0931/archive/2005/02/22/297547.aspx