How to put values from array into HashSet?

Write a test that checks that the rows of the array int [][] no number repeated. With this purpose I want to put string values in HashSet and compare the length of the string and resulting set.
But the compiler does not want to accept an int, and Integer. Prompt how to be?
April 19th 20 at 12:24
2 answers
April 19th 20 at 12:26
Solution
Probably you use the wrong type HashSet, that is different from Integer. For example, here it will be all OK:
public static void main(String args[])
{
 int[][] array = {{1, 5}, {1, 3}, {7, 8}};
 HashSet<Integer> yourHashSet = new HashSet<Integer>();

yourHashSet.add(array[0][0]);
yourHashSet.add(array[1][0]);
yourHashSet.add(array[2][0]);

 for (int i : yourHashSet)
System.out.println(i);
 }
Similarly, do not specify the type. Thank you - edmund24 commented on April 19th 20 at 12:29
April 19th 20 at 12:28
in the collection you cannot put primitives.

Find more questions by tags Java