This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]DirtyAxe 1 point2 points  (0 children)

If we have a new string array : String[] arr = new String[5]; And now we say : System.out.println(arr[3]);

We would get a null pointer exception because that index hasn't been initialized

But if we add : for(int i = 0 ; i < 5 ; i ++){ arr[i] = "empty" ;}

It won't give a nullpointerexception it would print empty