Null pointer exception? *SOLVED*
I know what the exception itself means, but I'm confused at how I'm triggering it in this situation;
Code:
Star str3 = null;
for (int i=0; i<20; ++i) {
str3 = new Star();
str3.x=(Math.random()*700-320);
str3.y=(Math.random()*700-240);
if (str3!=null) {
Driver.starary.add(i,str3);
}
}
I used code that was almost the EXACT same (just with more variables being set) and it works fine, so I'm confused at how this doesn't.
str3 is not used anywhere else, and x and y are doubles.
Can anyone see whats wrong?