java: 跳过后面if语句的if语句

java: if statement which skips the following if statement

我有一个二维字符串数组,我将通过它逐行查找最小值。当我找到最小值时,我将找到的最小值的行添加到 ArrayList 以在下一次迭代中跳过该行以找到数组的第二小数。我一直这样做,直到每个行号都是 ArrayList 的一部分。

到目前为止看到我的代码:

List assignedRow = new ArrayList();    
for(int t = 0; t < excelMatrix.length-1; t++){    
double lowest = Double.parseDouble(excelMatrix[0][1]);
    int row = 0, column = 0;    

    for(int r = 0; r < excelMatrix.length-1; r++){                      
        if(assignedRow.contains(r) == true) continue;               
        for(int c = 1; c < excelMatrix[r].length; c++){             
            double value = Double.parseDouble(excelMatrix[r][c]);
            if(lowest > value) {
                lowest = value;
                row = r;    
                column = c; 
            }   
        }   
    } 
    assignedRow.add(row);
}

代码到目前为止工作正常,直到最小值出现在第 0 行。之后它总是执行继续条件。

我现在正在寻找能让我回到 for 循环的东西,使用下一个更高的 r,它不是 ArrayList 的一部分。

希望我说清楚了我的问题。

我希望这会奏效。

  List assignedRow = new ArrayList();
    double lowest = 0;
    while (assignedRow.size() < excelMatrix.length) {

        // find intial lowest value from non assign row to compare
        for (int t = 0; t < excelMatrix.length - 1; t++) {
            if (!assignedRow.contains(t)) {
                lowest = Double.parseDouble(excelMatrix[t][0]);
                break;
            }
        }

        int row = 0, column = 0;
        for (int r = 0; r < excelMatrix.length - 1; r++) {
            if (assignedRow.contains(r)) continue;
            for (int c = 0; c < excelMatrix[r].length; c++) {
                double value = Double.parseDouble(excelMatrix[r][c]);
                if (lowest > value) {
                    lowest = value;
                    row = r;
                    column = c;
                }
            }
        }
        assignedRow.add(row);
    }

如果最低值存储在任何行的第一列,您的代码将无法运行,因为您从列索引 1 开始迭代(第三个 for 循环 int c=1lowest = Double.parseDouble(excelMatrix[0][1]