Initialization of an ArrayList in one line
In Java, you can initialize an ArrayList in one line using different approaches depending on your needs. The most common are new ArrayList(Arrays.asList("A","B","C")) for a modifiable list, new ArrayList(List.of("A","B","C")) in Java 9+ for concise syntax, or Collections.addAll(new ArrayList(), "A","B","C") for clean…
Answered Mar 9, 2026 · 1.1K Views Read answer →