fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. int[][] array = new int[2][];
  13. System.out.println("array[1] is " + array[1]);
  14. System.out.println("that is, it can indeed be null: " + (array[1] == null));
  15.  
  16. // Confirming the NullPointer:
  17. try {
  18. System.out.println(array[1][0]);
  19. } catch (NullPointerException expected) {
  20. expected.printStackTrace();
  21. }
  22. }
  23. }
Success #stdin #stdout #stderr 0.15s 57640KB
stdin
Standard input is empty
stdout
array[1] is null
that is, it can indeed be null: true
stderr
java.lang.NullPointerException
	at Ideone.main(Main.java:18)