package com.usr.collections;
import java.util.HashSet;
import java.util.Set;
public class SetToArray {
public static void main(String[] args) {
Set<String> set = new HashSet<String>();
set.add("one");
set.add("two");
set.add("three");
set.add("four");
set.add("five");
set.add("six");
convertSetToArray(set);
}
private static void convertSetToArray(Set<String> set) {
String[] strArr = set.toArray(new String[set.size()]);
System.out.println("converted to array");
for (int i = 0; i < strArr.length; i++) {
System.out.println(strArr[i]);
}
}
}
No comments:
Post a Comment
Note: only a member of this blog may post a comment.