switch()语句中能放的数据类型
一 Java7之前
switch 只能支持byte short char int或者对应的包装类以及Enum枚举类型。
二 Java7之后
switch 增加了 String 类型
三 Java8之后
switch支持10种类型 基本类型:byte char short int 对于包装类 :Byte Short Character Integer String enum
并且不能往switch()中存放null,这样会报错空指针,虽然再多循环中switch效率会超过 if else if,很多时候还是使用if else。