Код: Выделить всё
public static void main(String[] args) {
int[] a1 = {1, 3, 6, 8, 10, 11, 14, 17, 21};
int[] a2 = {2, 4, 8, 9, 12, 14, 15};
HashSet result = new HashSet(Arrays.asList(a1));
Iterator it = result.iterator();
while(it.hasNext()) {
System.out.println(it.next());
}
System.out.println(result.toString());
}
}
Подробнее здесь: https://stackoverflow.com/questions/782 ... ts-in-java