Java switch vs if/else

View this thread on: d.buzz | hive.blog | peakd.com | ecency.com
·@nik8singh·
0.000 HBD
Java switch vs if/else
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
👍 ,