java 14 nullpointerexception code example Example 1: nullpointerexception java Integer num; num = new Integer(10); Example 2: nullpointerexception java int x; x = 10;