i'm currently trying to add items to an generic "array" of arraylists but for some reason i keep getting a null pointer exception. The Structure is initialised and both my array index reference and the reference to the object i'm passing in are both visible within the body of code right before the exception occurs. I'm almost sure its down to the way i either declared the data structure or my way im trying to add it in. Any advice would be appreciated. Thanks in advance
ArrayList<Site>[] group = (ArrayList<Site>[])new ArrayList[entranceSites.size()];
group[i].add(sIndex(path));
sIndex
is a function I'm using to convert integers to graph sites and the object is not null when I'm passing it in so i'm sure its not the problem. I is initialised and also visible to the program.
ArrayList
? Why notArrayList<ArrayList<Site>>
?? – MadProgrammer Oct 24 '14 at 0:42group[i]
isnull
as you've not created anArrayList
for that element...but your code is so incomplete as to not to be able to make a judgment call... – MadProgrammer Oct 24 '14 at 0:43ArrayList
... – MadProgrammer Oct 24 '14 at 0:44List<List<Site>>
. – David Conrad Oct 24 '14 at 1:57