At present, the syntax of switch statements is highly constrained. It is not as powerful as the if-else construct. With if-else constructs, you can define and match complex patterns; but not with the switch construct. Also, the syntax of switch is verbose, which makes it visually annoying. This can lead to error-prone code that can be difficult to debug.
Let's work with an example to show all of these issues. The following example defines an enum, Size. The Shirt class defines a setSize() method, which accepts Size and accordingly assigns an integer value to the instance variable, length:
enum Size {XS, S, M, L, XL, XXL}; class Shirt { private int length; public void setSize(Size size) { switch(size) { case XS : length = 10; System.out.println(length); ...