Reputation: 5086
I am writing a for loop as follows:
for(int i = row, int j = col; i < rows, j < cols; i++, j++)
However, it appears Java isn't liking it... Is there any way I can achive something similar?
Thanks!
Upvotes: 1
Views: 2406
Reputation: 4836
for(int i = row,j = col; i < rows&& j < cols; i++, j++)
you can't have multiple declarations in for loop
and should have single boolean
expression
Upvotes: 0
Reputation: 3313
The second expression needs to be a boolean expresion, so
i < rows, j < cols
is not a boolean. You could try
i < rows && j < cols
Upvotes: 1
Reputation: 2434
use &&. Also, int
only once.
for(int i = row, j = col; i < rows && j < cols; i++, j++)
Upvotes: 6