【发布时间】:2020-10-31 12:59:59
【问题描述】:
当我在我的 Eclipse IDE 中安装 Sonarlint 插件时,我在 Sonar Report 中遇到了上述(标题)主要问题。
代码是:
public class Demo
{
public static final Map<String, String> CARD_TYPES;
static
{
CARD_TYPES = new HashMap<String, String>()
{
{ //Move the contents of this initializer to a standard constructor or to field* initializers
put("visa", "001");
put("diner", "002");
}
};
}
//..code goes here
}
查询是:在上面的静态块中究竟应该做什么,到 解决上述问题?
【问题讨论】:
标签: java hashmap static-block