The base class has a method called getRandomNumber() which will return some random integer
value. I need to use this method to generate a random integer value in such a way that I get values between 1 to 15. Also , I need to fill the array ‘array’ with random numbers from 1 to 15 without repeating any of the numbers. Currently , I have no idea how to do that. All I know a For loop is required here , also an IF block so I can make sure I am entering numbers from 1 to 15. Hints please.
will give you a random number between 1 and 15.
You just need to keep repeating this until you have all the numbers between 1 and 15.
However, as the numbers are random that could theoretically never happen.
A better way is to add the numbers 1 to 15 to a List, use Collections.shuffle to shuffle the list and then generate an array from that list.