If we are using too many conditional ifelse statements it will impact performance since JVM will have to compare the conditions. We can think of using a switch statement instead of multiple ifelse if possible. switch statement has a performance advantage over ifelse.

Non-compliant Code Example

int index = 1;
int nb = 2;

if (nb > index) {
    nb = nb + index;
} else {
    nb = nb - 1;
}
if (nb != index + 1) {
    nb = nb + index;
} else {
    nb = nb - 1;
}

Compliant Code Example

int index = 1;
int nb = 2;

if (nb > index) {
    nb = nb + index;
} else {
    nb = nb - 1;
}