0

How can I randomly select elements from an array and move them to different smaller arrays with no repetition.

For example my original array has the numbers 1-52 in it (representing each card in a standard deck). I want to randomly place each card in a pile without any repetition (like a game of solitaire).

Is there a a function for random selection like this?

Shady
  • 95
  • 7
  • 2
    Create your array with all the possible numbers. Shuffle the array randomly the grab the first N desired elements. – Steve Kuo Sep 29 '17 at 16:39
  • So generally you want to show what you've tried so far when asking a question. But to give a quick answer, a combination of the Java Random class and using an array list where you can remove the card from the "deck" and place it in a pile (new array list) could work. – Michael Platt Sep 29 '17 at 16:40

0 Answers0