为set集合排序

时间:2020-06-18 16:00:27   收藏:0   阅读:71

public static void main(String[] args) {
  HashSet<String> has = new HashSet<String>();
  has.add("");
  has.add("1");
  has.add("0");
  has.add("3");
  has.add("2");
  has.add("2");
  has.add("4");
  System.out.println(has);
  TreeSet<String> tree = new TreeSet<String>(has);
  tree.comparator();
  System.out.println(tree);
}

输出为

技术分享图片

 

原文:https://www.cnblogs.com/wangjianl/p/13157953.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!