The switch in Java does not have the convenience of C #. in C #, string can be used. Java and C ++ can only use integer types.
From: http://hi.baidu.com/%CE%BA%DE%A8/blog/item/85eaa10376c74c7d3912bbb4.html
Only int-type values can be placed in the brackets behind the switch.,Note that only the int type can be put, but the byte, short, and Char Types can also be put, because byte, short, and Shar can be automatically upgraded (automatically converted) to intYou can put them in another way. To put it bluntly, the byte, short, and Shar types you put will be automatically converted to the int type (extended, automatically converted, and secure ), in fact, the last put is the int type!
The principle is as follows: in Java, eight basic data types are involved in conversion. The boolean type cannot be converted to the boolean type, and the boolean type cannot be converted to other types, so the remaining 7 types are based on the number range of their tables (that is, the maximum number size that can be expressed, for example, char is 0 to 65535, byte is-128 to positive 127) sort byte, short, Char, Int, long, float, and double.
Rules:
1. small to large conversion (width), automatic conversion, sometimes it will be automatically upgraded to a large type, such as switch
2. Large to small conversions (narrowing) must be forced to convert the type, so long cannot work. If you want to do so, you have to convert it to (INT) Long. Similarly, float and double do not work. If you want to do so, you can turn it upside down.