In the above scenario, they are the same except for speed. If/ elsewill be faster than the Ifs series , since instructions are elseskipped if the condition is met If. On the other hand, in the Ifs series, each condition is evaluated separately.
, , , If/else If . :
// this:
if(x <= 0) {
x = 1;
}
else { // only true if x started out > 0
x = 37;
}
// is different from this:
if(x <= 0) {
x = 1;
}
if(x > 0) { // always true in this version
x = 37;
}