在一个3x3的二维矩阵里面随机的用0或1填充,找出该矩阵里面的相同行或者列

package exercise_7;

public class Exercise7_10 {

public static void main(String[] args) {

    int[][] test = new int[3][3];
    for (int i = 0; i < test.length; i++) {
        for (int j = 0; j < test[i].length; j++) {
            int t = (int) (Math.random() * 2);
            System.out.print(t + " ");
        }
        System.out.println();
    }//自动生成一个3—3的数组

    boolean flag=true;
for (int i = 0; i < test.length; i++) {
    flag=true;
    for (int j = 0; j < test[i].length-1; j++) {//判断相同行
        if (test[i][j]!=test[i][j+1]) {
            flag=false;
            if (flag) {
                System.out.println("All is on row "+i);
                break;
            }
        }
    }
    for (int j = 0; j < test[i].length-1; j++) {//判断相同列
        if (test[j][i]!=test[j+1][i]) {
            flag=false;
            if (flag) {
                System.out.println("All is on column "+j);
                break;
            }
        }
    }
}


}

}


```这是我写的程序,但是我的程序没有输出,我不知道是因为什么,求告知
 for (int i = 0; i < test.length; i++) {
            for (int j = 0; j < test[i].length; j++) {
                int t = (int) (Math.random() * 2);
                test[i][j] = t;//需要给数组赋值
                System.out.print(t + " ");
            }
            System.out.println();
        }//自动生成一个3—3的数组