Initialization of an ArrayList in one line

Source: https://stackoverflow.com/questions/1005073/initialization-of-an-arraylist-in-one-line
It would be simpler if you were to just declare it as a List - does it have to be an ArrayList?
List<String> places = Arrays.asList("Buenos Aires", "Córdoba", "La Plata");
Or if you have only one element:
List<String> places = Collections.singletonList("Buenos Aires");
This would mean that places is immutable (trying to change it will cause an UnsupportedOperationException exception to be thrown).
To make a mutable list that is a concrete ArrayList you can create an ArrayList from the immutable list:
ArrayList<String> places = new ArrayList<>(Arrays.asList("Buenos Aires", "Córdoba", "La Plata"));

Không có nhận xét nào:

‘Connection lost’ / ‘Invalid origin!’ Error with n8n >= 1.87.0 behind Cloudflare Tunnel

 https://community.n8n.io/t/solved-connection-lost-invalid-origin-error-with-n8n-1-87-0-behind-cloudflare-tunnel/99913/1 The Solution:  The ...