import java.util.HashSet 中来创建一个 String 的 TreeSet;输出:
导入 java.util.TreeSet;
导入 java.util.Set;
public class HashSettoTreeSet{
public static void main(String[] args) {
HashSethashset = new HashSet ();
hashset.add(E1”);
hashset.add(E2”);
hashset.add(E3”);
hashset.add(E4”);
hashset.add(E5”);
System.out.println(HashSet: ”+ 哈希集);
// 使用 HashSet
Settreeset = new TreeSet (hashset);
System.out.println(TreeSet: ”);
for(String e : treeset){
System.out.println(e);
}
}
}
HashSet: [E1, E2, E3, E4, E5]
TreeSet: [E1, E2, E3, E4, E5]
Please disable your ad blocker and refresh the window to use this website.