lundi 17 août 2020

What is faster? 2 if or if else [closed]

I have this code

        if(arr[i] > 0) {
            positive += 1;
        }
        if(arr[i] < 0) {
            negative += 1;=
        }

The first condition is not relevant for the second one. Should I left it like that or put else if instead of 2 separated if? Does it make execution time different? What is more readable?

Aucun commentaire:

Enregistrer un commentaire