Help!

I’m using java array literals for my levels (bad form, I know, but I’m pressed for time and want to have as much time as possible creating content) but it keeps saying my arrays are null. This is the offending code:

protected Integer[][] rawLevel =
 {
 {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
 {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
 {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
 {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
 {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
 {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
 {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
 {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
 {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
 {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
 {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
 {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}
 };
Any help with this would be greatly appreciated

Comments

gavin5564
17. Dec 2011 · 07:47 UTC
Not sure what language you are using but perhaps declare a new int array then initialize it in a constructor..
17. Dec 2011 · 07:49 UTC
Well, that should work! Can you pastbin you code?
17. Dec 2011 · 07:49 UTC
I don’t think you can define 2D Arrays using literals in Java. Not without specifying the first dimension, anyway.
17. Dec 2011 · 07:52 UTC
… I see I’m not the only one procrastinating.
Jack
17. Dec 2011 · 08:03 UTC
@The Jahn you can define 2D Arrays with literals, I did it in my warmup game and there were no problems whatsoever. I’ll try out the string idea, thanks
Jack
17. Dec 2011 · 08:08 UTC
and it’s STILL returning null! the sheer amount of irritation I’m feeling right now is beyond mere words
Jack
17. Dec 2011 · 08:35 UTC
ah, found out what it was. I was declaring it in the class, but calling the function that needs it from the superclass’ constructor, so it didn’t set it before trying to read it