#index out of bounds ;-;

29 messages · Page 1 of 1 (latest)

alpine nebulaBOT
#

This post has been reserved for your question.

Hey @serene ibex! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

hallow flower
#

yeah that line alone wont help much

#

seems like you iterate too high

#

something like

#
for(int i = 0; i<=10; i++){
}

instead of

for(int i = 0; i<10; i++){
}
#

yeah this is a mess

#

readability is 0

alpine nebulaBOT
#

If you are finished with your post, please close it.
If you are not, please ignore this message.
Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.

hallow flower
#

let me try and disentangle this

#

that is not the problem

#

fieldSize[mine[i][0]+1][mine[i][1]] != 9

#

this is

#

sorry

#

updated my message

#

well the problem is that mine[i][0]+1 can evaluate to 10

#

well

#

there you have it

#

if(mine[i][0]+1 <=fieldSize.length-1){ is true for 9

#

9+1 = 10

#

ah no

#

you added the one here also

#

you dont check for mine[i][1]

#

I guess

#

yeah but you have a call to fieldSize[mine[i][1]+1] before the check

#

in between the checks I should say

#

just make a sysout with mine[i][0]+1 and mine[i][1]+1 before you do all that so you can see for yourself in the console

bitter sail
#

Protip: clarifying printlns are always good for finding errors

#

What represents the value storaged in a position of the vector mine?

In the if statement is not being compared the index, but the value storaged in what the the index points summed with 1