Collection<String> col = new HashSet<>();
Object[] objArray = col.toArray();//可以转换成数组遍历
for(int i = 0;i < objArray.length ; i++){
System.out.println(objArray[i]);
}
//也可以使用迭代器遍历
Iterator it = col.iterator();
while(it.hasNext()){
String s = (String)it.next();
System.out.println(s);
} |