swtich能否作用在byte、long、String上?

  • 早期JDK,switch(expr),expr 可以是 byte、short、char、int。
  • JDK 1.5 开始,引入了枚举(enum),expr 也可以是枚举
  • JDK 1.7 开始,expr 还可以是字符串(String)。
  • 长整型(long)是不可以的

 

 

  

来一道刷了进BAT的面试题?

posted @ 2019-11-17 22:25  ConstXiong  阅读(329)  评论(0编辑  收藏  举报