Collection literals didn't make it into Java 8, but it is possible to use the Stream API to initialize a list in one rather long line:
List<String> places = Stream.of("Buenos Aires", "Córdoba", "La Plata").collect(Collectors.toList());
If you need to ensure that your List
is an ArrayList
:
ArrayList<String> places = Stream.of("Buenos Aires", "Córdoba", "La Plata").collect(Collectors.toCollection(ArrayList::new));