I’m trying to run this for loop;
for (int col= 0; grid[0].length; col++)
However every time I try to compile I get an error stating ‘incompatible types – found int but expected boolean’
I can’t work out what I’m doing wrong!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
the second statement: grid[0].length is an integer. The second statement in a for loop is a condition statement and needs to be a boolean.
If you’re trying to loop while col is less than the length of grid[0], then you need this as your second statement:
col < grid[0].length;