Ryan please can you tell me why do we need to create a new ArrayList object, so that we don't get a NullPointerException.
Havn't we initialised ar prior to the above line of code
Joined: May 19, 2005
I created Array of ArrayList
actual ArrayList syntax is ArrayList a = new ArrayList().
So i created an array of ArrayList ie
i created array size of 3 each of type arrayList so at this point ar,ar,ar are just variables of type ArrayList are created but are pointing to null . so until unless we redirect this from null to actual Arraylists they will be with null. and accessing a null object produces null pointer exception.
by assiginig where k2 = 0,1,2
we are redirecting the variable to ArrayList object.
I hope i cleared ur doubt.
Joined: Jan 09, 2004
subject: getting a Null pointer exception at this point