Java多重判断的简化
http://my.oschina.net/u/1455908/blog/398481
package com.bjs.test;
import java.util.Map;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableMap;
public class TestIf {
public static void main(String[] args) {
TestIf t = new TestIf();
int result = t.testMapReturn("A");
System.out.println(result);
}
private int testMapReturn(String gradle){
Map<String, Integer> configs = ImmutableMap.of("A",200,"B",4);
Preconditions.checkNotNull(gradle);
Integer result = configs.get(gradle);
if(result==null){
return 0;
}
return result;
}
} 相关推荐
Lzs 2020-10-23
聚合室 2020-11-16
零 2020-09-18
Justhavefun 2020-10-22
ChaITSimpleLove 2020-10-06
周游列国之仕子 2020-09-15
afanti 2020-09-16
88234852 2020-09-15
YClimb 2020-09-15
风雨断肠人 2020-09-04
卖口粥湛蓝的天空 2020-09-15
stulen 2020-09-15
pythonxuexi 2020-09-06
abfdada 2020-08-26
梦的天空 2020-08-25