I want to create a list of options for testing purposes.
(我想创建用于测试目的的选项列表。)
At first, I did this:(首先,我这样做:)
ArrayList<String> places = new ArrayList<String>();
places.add("Buenos Aires");
places.add("Córdoba");
places.add("La Plata");
Then I refactored the code as follows:
(然后,我将代码重构如下:)
ArrayList<String> places = new ArrayList<String>(
Arrays.asList("Buenos Aires", "Córdoba", "La Plata"));
Is there a better way to do this?
(有一个更好的方法吗?)
ask by Macarse translate from so