Java switch vs if/else

in #java7 years ago

If a switch contains more than five items, it's implemented using a lookup table or a hash list (jump table). This means that all items get the same access time, compared to a list of if/else where the last item takes much more time to reach as it has to evaluate every previous condition first.

But these sorts of micro-optimizations are unlikely to affect the performance of your code. Implement whichever design is clearer and more maintainable

Coin Marketplace

STEEM 0.20
TRX 0.25
JST 0.039
BTC 97530.27
ETH 3454.73
USDT 1.00
SBD 3.06