Ok, so what I need help with is making a random array of "n" numbers, but the numbers cant be duplicated.
right now i have something like
import java.util.Random;
public class testing {
public static void main(String[] args) {
Random random = new Random();
int max = 10;
int numOfNumbers = 2;
int winningTicket[] = new int[max];
for (int i = 0; i < numOfNumbers; i++){
//+1 to eliminate 0, and get the max number given
winningTicket[i] = random.nextInt(max) + 1;
}
}
}
but this code will give duplicate numbers sometimes. how do i solve this problem?