The null Keyword : null « Class Definition « Java Tutorial






You can test if a reference variable is null by using the == operator. For instance.

public class MainClass {

  public static void main(String[] args) {
    String book = null;
    
    if (book == null) {
        book = new String();
    }
  }

}








5.21.null
5.21.1.The null Keyword