首页 新闻 赞助 找找看

报错:Cannot switch on a value of type String. Only convertible int values or enum constants are permitted求解???

0
悬赏园豆:20 [已解决问题] 解决于 2017-06-18 19:30

public int calRent(int days,String type){
  switch (type) {
  case "1":
   num=600*days;
   break;

  default:
   break;
  }
  
  return num;
 }

三生hn的主页 三生hn | 初学一级 | 园豆:184
提问于:2017-06-08 16:17
< >
分享
最佳答案
0

如果使用String类型的type值要JDK1.7版本以上的

收获园豆:20
杨杨yang | 菜鸟二级 |园豆:219 | 2017-06-09 02:18

1.8不行吗?

三生hn | 园豆:184 (初学一级) | 2017-06-09 17:19
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册