Reputation: 63
Currently I'm developing an Android app which draws a point on the coordinates input by the user. I'm rather new to java so please assist me. Cheers.
@Override
public void onDraw(Canvas canvas) {
float[] manualpointx ={100,200,300,400,500,600};
float[] manualpointy ={120,300,400,560,600,500};
for (int i = 0;i<100;i=i+1)
{
canvas.drawCircle(manualpointx[i], manualpointy[i], 5, paint);
invalidate();
}
}
The problem happens when canvas.drawcircle
is called and the app crashes.
Upvotes: 0
Views: 291
Reputation: 3742
Apparently you refer to manualpointx[i]
and manualpointy[i]
for i from 0 to 99 and the fact is that they are not defined for i greater than 5. You try to refer to a cell of an array that is out of the bounds of the array.
Upvotes: 1