Values & References5 / 16
Up next

null and NPE

class Main {
    public static void main(String[] args) {
        String s = null;
        // a reference may be null; a primitive may not
        System.out.println(s == null);
        try {
            s.length();
        } catch (NullPointerException e) {
            System.out.println("was null");
        }
    }
}
What you're solving

a reference with no object