As mentioned by others, there are several libraries and several posts available for you to get started. I just wanted to give you two approaches to achieve your goal.
For the case of 'generating a list of combinations that have not occured yet'
I understand this goal as you have a history of the draws and you want to generate a bunch of random number sets which have never occurred in the history. Basically you need first a random number generator and generate the lottery numbers. Then take this set of numbers and
try to find it in the historical data. If you found it, just start over and generate a new one. Based on my comment to the question you practically have the chance lets say (5200 / 47M) you find your numbers in the history list. Repeat this whole process until you get enough number.
For the case of 'generating a list of combinations that have occured already'
You basically need to find duplicates in the history list. Create a Set<Integer>
from each historical occurrence and start adding it to yet another set of Set<Set<Integer>>
.
If the number set you are adding already occurred during the processing, you get a false return from the add
method of this latter set. Then you just print or memorize the duplicate number set.