1. Can switch work on byte, long, and String?
It can be used on byte, but not on long. The switch can be a string type, String (it can be used on String after jdk1.7).
2. Extended summary:
- switch can act on: char, byte, short, int
- Switch can act on: the packaging classes corresponding to char, byte, short, int
- Switch cannot be used for: long, double, float, boolean, including their packaging classes