When you finish a large web job, you often encounter two problems, one of which is when the string type is judged to be equal, and the other is when a null pointer error occurs when the loop is discussed or applied in a separate situation.
1, Judge two string is equal and cannot be directly used with Span style= "FONT-FAMILY:CALIBRI;" >== or! = need equals () to determine, equal to return 1 Span style= "font-family: the song Body;" > java string with == equal compare values, where different declarative methods have an effect on the direct comparison of strings.
Example: String Str1=new string ("a"); String Str2=new string ("a"); STR1==STR2 output False Str1.equals (STR2) outputs true if such a declaration is made of String str1= "a"; String str2= "a"; STR1==STR2 output True str1.equals (str2) Output true
The general situation can be written in two ways of "or" to judge.
2. Null pointers are often present in objects with no specific class initialization, or the value of an object may be empty. When you write paging in the web, there are times when there are no errors at compile time but running times are wrong. At this point, the reason for throwing an exception is as if the user login function, the first only to determine the administrator and the normal user logon situation, and when the User provided form field "username" is empty, It is not possible to compare a null object directly to another object, and the JSP page where the code snippet is located throws (Java.lang.NullPointerException) a null pointer error. When paging the page to determine the range of page numbers, if the page number is two boundary value will be thrown empty, then the page will go to the beginning of the page.
You can set breakpoints in debug mode, step through, look down from the top, or look in the stack information that throws the exception. Multiple logical judgments and try catch to avoid null pointer errors.
Software Test jobs-problems encountered while developing a project