public class LoopSoup {
public static void main(String[] args) {
int i = 5;
int j;
while (i > 0) {
System.out.println(i);
i--;
j = 1;
while (j < 4) {
System.out.print(j);
j++;
}
System.out.println();
}
}
}
jshell> String name = null;
name ==> null
jshell> System.out.println(name.length());
| java.lang.NullPointerException thrown:
| at (#2:1)
You're trying to find the length of a string of characters referred to by the name variable. But the name variable has no value. So Java displays an error message.