Java: Null object

The built-in constant null is used to represent an uninitialized object.

It can only be assigned to objects and not to variables of primitive types.

The equal to operator (==) can be used to test whether an object is null.

package javaapplication22;

public class PrintString {

    public static void main(String[] args) {

        String s = null;
        if (s == null) { 
            s = new String();
            s = "Hi There!";



Series Navigation<< Java: Default constructor
Java: Default values >>