Anudeep Duvvuri wrote:How to get a random 4 digit number without repetition...
Please anyone help me its very urgent
Campbell Ritchie wrote:Try random selection from a declining population with a List of Integers [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] and a Random object to get the index.
Junilu Lacar wrote:I don't see much difference between this and Winston's suggestion to shuffle and take the first four or five. Shuffle is going to randomize the order.
Winston Gutkowski wrote:My suggestion: Make an array of single digits, shuffle it, and take the first 4 (or 5, if the first one is '0').
Winston Gutkowski wrote:I suspect Campbell and I were both typing at the same time; but by some miracle I happened to get in first.
Rooks Forgenal wrote:A simple ArrayList shuffle is the least amount of code but also gives you the least amount of control.
Rooks Forgenal wrote:Let's make it generic, shall we?