java – Return the maximum value of a row of a matrix without considering the diagonal coefficients

I have a the two-dimensional array :

0. | 0.0 | -0.8980387129971331 | -0.8900869793075101 | -0.8906789098245378 | 1.0104911316104093 | -0.8816392828513628
1. | -0.8998803800424156 | 0.0 | -0.8894871457733221 | -0.8897044897987794 | 1.1079409359304297 | -0.7105118305961893
2. | -0.8889556072705933 | -0.8924868056899387 | 0.0 | 1.1083728720261286 | 1.0098247893112775 | 1.099113864022297
3. | -0.8808751963282109 | 0.9280169284175466 | -0.8891630366886065 | 0.0 | -0.69121432906078 | -0.7092216479617963
4. | -0.8986589499572509 | -0.8921590617526629 | -0.8891630366344203 | -0.7057342552186525 | 0.0 | -0.7075934709028173
5. | -0.8988751964282238 | -0.8981045503211356 | -0.8891659511135326 | 1.0907466603012215 | 1.1072644730546006 | 0.0

And I want to get the maximum of a line without considering the diagonal coefficients.

I’m using the following funtion :

double maxQ(int s) {
    int()() actionsFromState = actions(s);
    double maxValue = Double.MIN_VALUE;
    for (int i = 0; i < actionsFromState.length; i++) {
        int() nextState = actionsFromState(i);
        int nexts = linearCheck(states, nextState);
        double value = Q(s)(nexts);

        if (value > maxValue)
            maxValue = value;

    }
    return maxValue;
}

But for example for the 4th line it returns me the value 0.0 while I want it to return: -0.7057342552186525.

It must return the maximum among all the values ​​except the value of the column 4.