Set to array
- Call toArray() static method
Object[] objects = collection3.toArray();
for (int i = 0; i < objects.length; i++) {
System.out.println(objects[i]);
}
Array becomes collection
- Call the static method asList() of the Arrays class
List strings = Arrays.asList(new String[]{
"AA", "BB", "CC"});