I am wondering if there's a one-line way of copying an array to a list than the following:
String array[] = new String[]{"1", "2", "3", "4" } ;
List list = new ArrayList();
for (int i=0; i< array.length; i++){
list.add(array[i] );
}
Edit: thanks for both informative answers, very helpful :)
List. Also,List<E>is an interface, so it cannot be instantiated: you may create anArrayList<E>or aLinkedList<E>instead.List<String>.