标签:
Integer[] ia = new Integer[] { 1, 2, 3, 1 }; Set<Integer> set = new HashSet<Integer>(); for (Integer i : ia) { if (!set.add(i)) { System.out.println(i + "重复"); break; } }
Integer[] ia = new Integer[] { 1, 2, 3, 1 }; Set<Integer> set = new LinkedHashSet<Integer>(); for (Integer i : ia) { set.add(i); } System.out.println(set); ia = set.toArray(new Integer[0]); }
Set<Integer> set = new HashSet<Integer>(); set.add(1); set.add(2); Set<Integer> otherSet = new HashSet<Integer>(); otherSet.add(2); otherSet.add(1); System.out.println(set.containsAll(otherSet)); //true otherSet.add(3); System.out.println(set.containsAll(otherSet)); //false
A = {1,2}
B = {1,2,3}
A ⊆ B
A < B
java.util.Set
A collection that contains no duplicate elements.
标签:
原文地址:http://www.cnblogs.com/zno2/p/4616271.html