- #1
Hiche
- 84
- 0
Well, the title pretty much sums up my question.
I came up with this. This should check for duplicates but the result isn't quite what I want.
Consider this array:
Well, this has three 1s and two 2s. I want it so it give me that we have three 1s and two 2s and removes them. How exactly do I do that?
Thanks.
Code:
public static int[] removeDuplicates(int[] x)
{
for (int i = 0; i < x.length; i++)
{
for (int j = i + 1; j < x.length; i++)
{
if (x[i] == x[j])
System.out.print("Found a duplicate!");
}
}
}
I came up with this. This should check for duplicates but the result isn't quite what I want.
Consider this array:
Code:
int[] array = { 1, 2, 3, 4, 5, 1, 2, 6, 1 };
Well, this has three 1s and two 2s. I want it so it give me that we have three 1s and two 2s and removes them. How exactly do I do that?
Thanks.