|
|
|
|
|
by oconnor0
5470 days ago
|
|
1) There is a literal syntax for Java:
entries = new ArrayList<Integer>() {{ add(3); add(4); }}
Unfortunately if you have warnings turned on in your IDE, it will complain about the lack of a serialVersionUID on your new class. This can be worked around via the `@SupressWarnings("serial")` annotation, but that hurts overall readability & code line count. That makes this technique less of a win than it would seem. |
|