Convert array to collection
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
public class Main {
public static void main(String[] args) {
String[] array = { "A", "B", "C", "D" };
List list = Arrays.asList(array);
Iterator iterator = list.iterator();
while (iterator.hasNext()) {
System.out.println((String) iterator.next());
}
}
}
Related examples in the same category