We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Based on what i understand, NullPointerException error is happening when some value is not initialize yet and we try to call it in a function. But looking at my code, I tried to re-initialize the values in NullPointerException error line but it seems that the error are still there. Can anyone help me with this?
sometimes multiple values in one line can be suspicious candidates, maybe you're looking at the wrong one?
in the line before your error line say
or post your code....
which line holds the error?
can i give u a link to my code? it kinda long
float distance = dist(ballPos.x, ballPos.y, tempBall.ballPos.x, tempBall.ballPos.y);
this is your problem:
tempBall itself is ok though
since tempBall is coming from table.b_arr[i]; make sure tempBall.ballPos is set there
the same error come out when i tried to set it up
is that your code??
you cannot just reset it there!!!
but i set it in my Ball class. i have no idea where should i reset it. im really new with computing, im sorry
ok, several issues
first don't call
repelin the constructor of class Ball (line 35) !!!!!!!
class Tableyou say
16 balls, ok, but in
get_array_ballyou define only 14 balls, so it crashes with number 15 (say 14 in
at the moment, everywhere it says
< table.b_arr.lengthin a for-loop it will crash
i editted the array size to 14.
so, where should i call it? actually, i modify the code from this pde file,
to make it fit my program. i just change the array and the object in the array. in that code, they call repel in the class Ball.
yeah, it works in the original code because they use an arrayList instead of a fixed array as you have
just don't call repel at all for now.
(Repel has the function to make sure that the balls don't overlap each other in the beginning. Not important.)
okay, i got it. thanks mate. appreciate your help a lot. now i can proceed with it. :D