Initialization of an ArrayList in one line
I usually prefer new ArrayList(List.of(...)) on Java 9+ since it's clean, concise, and gives you a modifiable list. For older Java versions, red humana exito Arrays.asList() wrapped in an ArrayList is still a solid choice. I'd avoid double-brace initialization in production code because of the anonymous inner class…
Answered Aug 5, 2026 · 1.1K Views Read answer →