What is Double Brace initialization in Java?

前端 未结 13 2288
旧时难觅i
旧时难觅i 2020-11-21 07:22

What is Double Brace initialization syntax ({{ ... }}) in Java?

13条回答
  •  情深已故
    2020-11-21 08:01

    you mean something like this?

    List blah = new ArrayList(){{add("asdfa");add("bbb");}};
    

    it's an array list initialization in creation time (hack)

提交回复
热议问题