jeudi 26 mai 2016

How to check NULL in if condtion?

I don't want to use try block to catch the exception I just want to check null with if condition.when i try that it is giving me the null pointer exception.

 public class test {

public static void main(String[] args) {

String name=null;
 if(name.equals(null)){
  System.out.println("null");
}
  System.out.println("done");
   }
     }

Aucun commentaire:

Enregistrer un commentaire