I need to get the unique values of the first array index and this is how I tried.
public class Array {
public static void main(String[] args) {
int[][] array = {
{100, 12 , 0, 3},
{100, 177, 0, 3},
{100, 233, 0, 3},
{100, 144242, 0, 3},
{100, 14, 0, 4},
{100, 12234, 0, 4},
{100, 134, 1, 4},
{2, 15, 0, 3},
{23, 1533, 0, 3},
{23, 1322, 1, 4},
{23, 13, 1, 4},
{23, 122, 1, 4},
{1321, 142, 1, 4},
{1321, 133,1, 4},
{3, 16, 0, 5},
{55, 1003, 0,3},
{553, 1002, 2, 6},
{31, 162, 0, 5},
{7, 1626, 0, 5},
{7, 2336, 0,5}
};
boolean isUnique = true;
for(int i=0; i<= array.length; i++)
{
for (int j = 0; j < 1; j++)
{
if (array[j]==array[j])
{
int riid = array[i][j];
Set<Integer> uniqueNumbers = new HashSet<Integer>(Arrays.asList(riid));
System.out.println(riid);
}
}
}
}
}
my output must be 100, 2, 23, 1321, 3, 55, 553, 31 and 7. but, it doesn't give me unique values. It prints 100 100 100 100 100 100 100 2 23 23 23 23 1321 1321 3 55 553 31 7 7
How can I get the unique values of this output. i thought Set<Integer> uniqueNumbers = new HashSet<Integer>(Arrays.asList(riid));
would help. but, it didn't.