talking about java performance .. what is better? if..else or multiple simple if
if( condition ) {
some_code;
return value;
}
else if( condition ) {
so
Depends on the situation.
If the conditions are mutually exclusive, use else
. This will cause Java to not check any of the conditions after the one that is found to be true.
If they are not mutually exclusive, then using a list of if
without else could cause multiple cases to occur.
In your case, with returns in each, the performance will be the same because the same number of comparisons will need to be done no matter what.