Поскольку у меня есть Arraylist int массивы, который содержит дубликаты, я хотел бы использовать хэшсет. К сожалению, я не могу использовать хэшсет по своему желанию: < /p>
System.out.print("\nTESTs\n");
ArrayList list = new ArrayList();
list.add(new int[]{1,2,3});
list.add(new int[]{5,1,1});
list.add(new int[]{1,2,3});//duplicate
list.add(new int[]{5,1,3});
Set set = new HashSet(list);
System.out.println("Size of the set = "+set.size());
ArrayList arrayList = new ArrayList(set);
System.out.println("Size of the arrayList = "+arrayList.size());
for (int[] array:arrayList){
System.out.println(Arrays.toString(array));
}
< /code>
Это приводит к: < /p>
Size of the set = 4
Size of the arrayList = 4
[1, 2, 3]
[1, 2, 3] // duplicate still here
[5, 1, 1]
[5, 1, 3]
< /code>
может кто -нибудь сказать мне, где я ошибаюсь? < /p>
>
Подробнее здесь: https://stackoverflow.com/questions/283 ... int-arrays