没有合适的资源?快使用搜索试试~ 我知道了~
switch不能字符串比较解决方法
需积分: 50 35 下载量 15 浏览量
2017-01-09
15:52:30
上传
评论
收藏 657B TXT 举报
温馨提示
试读
2页
switch不能字符串比较解决方法
资源推荐
资源详情
资源评论
[java] view plain copy
public void switchCaseStr() {
Map<String,Integer> map=new HashMap<String, Integer>();
map.put("hello", 1);
map.put("haha", 2);
map.put("yes", 3);
map.put("in", 4);
String str="hello";
switch(map.get(str))
{
case 3:
System.out.println("yes");
break;
case 1:
System.out.println("hello");
break;
case 2:
System.out.println("haha");
break;
case 4:
System.out.println("in");
break;
default:
System.out.println("default");
public void switchCaseStr() {
Map<String,Integer> map=new HashMap<String, Integer>();
map.put("hello", 1);
map.put("haha", 2);
map.put("yes", 3);
map.put("in", 4);
String str="hello";
switch(map.get(str))
{
case 3:
System.out.println("yes");
break;
case 1:
System.out.println("hello");
break;
case 2:
System.out.println("haha");
break;
case 4:
System.out.println("in");
break;
default:
System.out.println("default");
资源评论
chumingyang8877
- 粉丝: 0
- 资源: 5
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功