ArrayList<String> places = new ArrayList<String>();
places.add("Buenos Aires");
places.add("Córdoba");
places.add("La Plata");
For example, there is a source like this, and I want to reduce the initialization syntax to one line, is there a good way?
java collections arraylist initialization
I think it'd be good to do it like this.
ArrayList<String> places = new ArrayList<String>(
Arrays.asList("Buenos Aires", "Córdoba", "La Plata"));
© 2024 OneMinuteCode. All rights reserved.