Java从HashSet中取元素

import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

public class TestHashSet {

 public static void main(String[] args) {
  Set set = new HashSet();
  set.add("one");
  set.add("two");
  set.add("three");
  
  Iterator it = set.iterator();
  
  while(it.hasNext()){
   System.out.println(it.next());
  }
 }

}

你可能感兴趣的:(Java)