1) I'm not so sure adding a value to the array before it has been validated is a good idea. That would be like having the line to the club,......inside the club... It can get confusing to the reader. Perhaps store the current number in a variable for validating, and if it passes allow it a home in the array, and if not just overwrite it on the next iteration of the loop. What happens when you reach the last number of the array? Wouldn't the test always be true since it is testing the number against itself?
2)if (array[i] == array[j]) Assuming you are testing what you think you are testing.... Does it make sense to i-- or i++ for every element of the array as it is being checked?
The posted algorithm suggests to check the entire array, and then decide to i-- and discard the current number, or i++ and keep the current number as unique.
Java allows you to leave the curly braces out in this case. Put them in anyway. The program is no different with or without them, the difference is to the reader of the code. Box up these 1-liner if statements just like the rest of the code and keep everything in a neat and orderly style.
if (userInput < 0)
i--;
if (i == 3)
break;
}
This just looks like crazyness with the indentation so far off and the braces missing.
Start back at the algorithm. Take the sample given in post #2 and break the steps down into smaller steps each. When you can no longer break the steps down it is time to start translating that into code. Make sure you have a full understanding of each step individually from start to finish and don't focus so much on the finished product or the big picture as you write code for each broken down step.