Creating Two dimensional arrays using nested-loop : I am trying to understand this code from the book. Using Java    

    int[][] grade = {{ 1, 0, 1},
        { 0, 1, 0},
        { 1, 0, 1}};
        for ( int i = 0; i < 3; i++) {
        for ( int j = 0; j < 3; j++) {
        if (i==j)
        System.out.print(grade[i][j] + grade[j][i] + " ");
        else
        System.out.print(grade[i][j] * grade[j][i] + " ");
        }
        System.out.println(" ");
        }

I understand the logic of a two dimensional arrays being rows and columns I just don't  understand how the answer came to be this. 

    2 0 1
    0 2 0
    1 0 2