Tag Archives: days and months multiplying

Error reporting: java.lang.nullpointerexception solution

The null pointer exception problem is mostly an error in integer automatic unpacking

Error code:

	 Integer a=null;
 	 if(a==1||a==null){    
        System.out.println("111");
     }

error reporting: java.lang.nullpointerexception

Error reporting reason:

Integer object is null. In the process of automatic unpacking, obj.xxxvalue will throw NullPointerException

Problem solving:

If you want to continue the multi conditional judgment, you should put the judgment empty in the first place

Modification code:

	 Integer a=null;
 	 if(a==null||a==1){    
        System.out.println("111");
     }

To avoid another null pointer like exception error, you need to master the knowledge of null in Java. You can refer to another article     What you should know about null in Java