为set集合排序


public static void main(String[] args) {
  HashSet has = new HashSet();
  has.add(1);
  has.add(0);
  has.add(5);
  has.add(12);
  has.add(1);
  has.add(4);
  System.out.println(has);
  TreeSet tree = new TreeSet(has);
  System.out.println(tree);
}

 运行结果