public static void main(String[] args) {
// When instantiating an array, you give it sizes, not indices
int[][] arr = new int[3][1];
// These are all the valid index combinations for this array
arr[0][0] = 3;
arr[1][0] = 5;
arr[2][0] = 6;
int max = 1;
// To use these variables outside of the loop, you need to
// declare them outside the loop.
int x = 0;
int y = 0;
for (; x < arr.length; x++) {
for (; y < arr[x].length; y++) {
if (arr[x][y] > max) {
max = arr[x][y];
System.out.println(max);
}
System.out.println(arr[x][y]);
}
}
// This print statement accesses x and y outside the loop
System.out.println(arr[x][y]);
}