I wrote the following code to walk half the diagonals of an array:
String[][] b = [a,b,c]
[d,e,f]
[g,h,i];
public void LoopD
Here is the code:
public void loopDiag(String [][] b) {
boolean isPrinted = false;
for (int i = 0 ; i < b.length ; i++) {
String temp="";
int x=i;
for(int j = 0 ; j < b.length ; j++) {
int y = j;
while (x >= 0 && y < b.length) {
isPrinted = false;
temp+=b[x--][y++];
}
if(!isPrinted) {
System.out.println(temp);
isPrinted = true;
}
}
}
}