I try to print simple HashSet in java 20 without success what am i missing here ?
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<int[]> result = new HashSet<>(Arrays.asList(a1));
Iterator<int[]> it = result.iterator();
while(it.hasNext()){
System.out.println(it.next());
}
System.out.println(result.toString());
}
}
HashSet
containing arrays, or should it be aHashSet<Integer>
? Arrays are not the best elements to be maintained in aHashSet
since, for example, arrays do not extendhashcode()