一、在Java中定义Map常量

1、使用静态代码块:

public static final Map map = new HashMap(); 
static {
map.put("key1", "value1");
map.put("key2", "value2");
}

2、简单定义Map常量

public static final Map<String, String> map = new HashMap<>() {
{
put("key1", "value1");
put("key2", "value2");
put("key3", null);
}
};

二、List常量定义方式

public static final List<String> list = Arrays.asList("1","2","3");