String[] array = {"9", "1", "2", "a", "3", "8"}; List listArray = Arrays.asList(array);// for (int i = 0; i < listArray.size(); i++) {// System.out.println(listArray.get(i));// }// hashset无序 只能有一个null HashSet hashSet = new HashSet<>(listArray); for (String hash : hashSet) { System.out.print(hash); } System.out.println(hashSet.add(null)); System.out.println(hashSet.add(null)); System.out.println("----------------------------------------------");// treeSet从小到大排序,不可重复,不能有null TreeSet treeSet = new TreeSet<>(listArray); for (String s1 : treeSet) { System.out.print(s1); } System.out.println("----------------------------------------------");// 保留原始顺序,只能有一个null linkedHashSet linkedHashSet = new linkedHashSet<>(listArray); System.out.println("判断linkehashset添加null值"); System.out.println(linkedHashSet.add(null)); System.out.println(linkedHashSet.add(null)); for (String s : linkedHashSet) { System.out.print(s); }