Efficiency: switch statements over if statements
PMD tells me A switch with less than 3 branches is inefficient, use a if statement instead. Why is that? Why 3? How do they define efficiency? Because a switch statement is compiled with two special JVM instructions that are lookupswitch and tableswitch . They are useful when working with a lot of cases but they cause an overhead when you have just few branches. An if/else statement instead is compiled into typical je jne ... chains which are faster but require many more comparisons when used in a long chain of branches. You can see the difference by looking at byte code, in any case I wouldn