Java / Arrays
How do I create a list from Array which is completely independent of the original array?
The fixed length list returned by asList method is used as an argument to create a new ArrayList which is later garbage collected.
The new ArrayList is independent of the original array and the changes to the list does not reflect on the array and vice versa.
Adding/removing elements could be performed in this list.
String[] myFruits1 = { "Apple", "Pineapple", "Strawberry" }; List<String> myFruitsList = new ArrayList<String>(Arrays.asList(myFruits1));
More Related questions...