Hello, If you use the code below then you will able to get the conversion of the collection to an array. So, you will able to get the solution for your problem:
Code:
import java.util.ArrayList;
import java.util.Collection;
public class convert {
public static void main(String argarrS[]) {
String str[] = { "one", "two", "three", "four", "five",
"six", "seven", "eight", "nice" };
Collection collection = new ArrayList();
for (int i = 0, n = str.length; i < n; i++) {
collection.add(str[i]);
}
String arrS[] = (String[]) collection.toArray(new String[0]);
for (int i = 0, n = s.length; i < n; i++) {
System.out.println(arrS[i]);
}
collection.remove(str[3]);
System.out.println(str[1] + " " + collection.contains(str[1]));
System.out.println(str[3] + " " + collection.contains(str[3]));
}
}
Bookmarks