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; } }
直接上代码,一个奇技淫巧
时间: 2024-10-11 09:41:41