I want to store random numbers from 1 to 60 in an array. When there are equal numbers in the rows, it is to generate another random number.
Type, can not be: 11 55 55 43 49 30, but should be 11 55 52 43 49 30. There should be no repetitions.
I made this code that generates normally, but wanted to remove the repeated numbers from the lines and put new numbers that are not equal.
package Tentativa;
import java.util.Random;
public class Loteria {
public static void main(String[] args) {
int[][]mega = new int[7][6];
int[][]numero = new int[7][6];
Random gerador = new Random();
for(int x=0; x<7; x++) {
for(int y=0; y<6; y++) {
mega[x][y] = gerador.nextInt(60) + 1;
}
}
for(int x=0; x<7; x++) {
for(int y=0; y<6; y++) {
System.out.print(mega[x][y] + " ");
}
System.out.println();
}
}
}