A basic for statement includes
- 0..n initialization statements (
ForInit)
- 0..1 expression statements that evaluate to
boolean or Boolean (ForStatement) and
- 0..n update statements (
ForUpdate)
If you need multiple conditions to build your ForStatement, then use the standard logic operators (&&, ||, |, ...) but - I suggest to use a private method if it gets to complicated:
for (int i = 0, j = 0; isMatrixElement(i,j,myArray); i++, j++) {
// ...
}
and
private boolean isMatrixElement(i,j,myArray) {
return (i < myArray.length) && (j < myArray[i].length); // stupid dummy code!
}