Is there a better alternative to using Arrays.asList as a List bulk initializer? Of concern is that this one is verbose and involves an extraneous class and method.
List<Double> myList = new ArrayList<Double>(Arrays.asList(3.01d, 4.02d, 5.03d));
Edit: This question pertains to a bulk initialization which would usually have more than the three values shown in the example.
If you know that you won’t need to add anything to the list later, you can just do
I’m pretty sure the list returned from
Arrays.asListcan be modified, but only in that you can change the elements that are there — you can’t add new elements to it.