如何初始化静态地图?
Map
import java.util.HashMap;import java.util.Map;public class Test { private static final Map<Integer, String> myMap = new HashMap<Integer, String>(); static { myMap.put(1, "one"); myMap.put(2, "two"); } private static final Map<Integer, String> myMap2 = new HashMap<Integer, String>(){ { put(1, "one"); put(2, "two"); } };}
鸿蒙传说
慕标5832272
相关分类