[Solved] This code is not working [closed]


Both your snippets are incorrect.

You are misusing the post increment operator.

if(data[counter]<data[counter++])

will never be true, just like

if(data[counter]<data[counter])

will never be true.

The post increment operator returns the original value of the incremented variable.

It’s not clear why you are incrementing counter in the loop body anyway. You should only increment it in the for statement. And in order to find the minimum, you must compare data[counter] to minimum_angle:

double minimum_angle = Double.MAX_VALUE;
for(int counter = 0; counter < data.length; counter++) {
    if(data[counter] < minimum_angle) {
        minimum_angle = data[counter];
    }
}

solved This code is not working [closed]