「 JAVA 」 七月 12, 2020
为什么不建议使用双括号初始化?
文章字数 2.6k 阅读约需 2 mins.
Map<String, Object> map = new HashMap<String, Object>() {{
put("name", "Alpha");
put("age", 8);
}};
以下内容引自 The Java™ Tutorials - Initializing Fields:
查看全文Initializing Instance Members
Normally, you would put code to initialize an instance variable...