I am trying to generate a 5 digit int array in Java and am having trouble on where to start. None of the numbers in the array can be duplicates. I can generate
int
As an alternative, just sort the array and iterate it.
List myList = new List() { 1, 1, 2, 3, 4, 5, 5, 7 , 1, 7}; myList.Sort(); for (int i = myList.Count - 1; i > 0; i--) { if (myList[i] == myList[i - 1]) myList.RemoveAt(i); }
But of course it's best not to get any duplicates to start with.