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.18
TRX 0.15
JST 0.029
BTC 62571.47
ETH 2429.90
USDT 1.00
SBD 2.66