You had to create a 5x5 array by printing random characters from the ASCII table.
public class ExercicioClass01g {
static Scanner ler = new Scanner(System.in);
public static char mat[][] = new char[5][5];
public static void gera(int lin, int col){
Random gerador = new Random();
int ctlin,ctcol;
for(ctlin=0;ctlin<lin;ctlin++)
for(ctcol=0;ctcol<col;ctcol++)
mat[ctlin][ctcol]=(char)(gerador.nextInt(25)+65);
}
public static void exibe(int lin, int col){
int ctlin,ctcol;
for(ctlin=0;ctlin<lin;ctlin++){
for(ctcol=0;ctcol<col;ctcol++)
System.out.print(mat[ctlin][ctcol]+" ");
System.out.println();
}
}
public static void main(String[] args) {
// TODO Auto-generated method stub
gera(5, 5);
exibe(5,5);
}
I was able to print but I can not make the letters ( char
) not repeat in the array.