I have to write an application where I retrieve a lotto numbers that I stored as strings in a database and compare them with the winning lotto number that was generated by the application itself.
I am a bit stuck with this one.
I started of with retrieving the 6 lotto numbers from the database and adding it to an array list.
ArrayList<String> listTwo = new ArrayList<String>();
ResultSet set = state.executeQuery("SELECT * FROM NumbersClients");
while(set.next())
{
String numbers = set.getString(1);
listTwo.add(numbers);
}
The numbers I generated randomly I saved in an ArrayList and then converted to an Integer array.
Integer[]entries = lottoDraw.toArray(new Integer[lottoDraw.size()]);
Any pointers perhaps as to how I can retrieve each individual lottodraw from ‘listTwo’ and compare them to the winning number(‘entries’) and thus estblish 3,4,5 matches etc.
Thank you
Why not store the numbers individually in the database. Then generate the winning numbers and query the database. E.g.
This way you avoid retrieving large amounts of irrelevant data