I'm attempting to set up a 2 dimensional array of the alphabet in java. My first attempt (doesn't work):
char[][] arr=new char[4][7];
for(int r=0; r<arr.length; r++){
for(int c=0; c<arr[r].length; c++){
for(char i=65; i<91; i++){
arr[r][c]=i;
System.out.print(arr[r][c]);
}
}
System.out.println();
}
My second attempt(does work, but seems convoluted):
char[][] arr2=new char[4][7];
char i=65;
for(int r=0; r<arr2.length; r++){
for(int c=0; c<arr2[r].length; c++){
arr2[r][c]=i;
System.out.print(arr2[r][c]);
if(i<91){
i++;
}
}
System.out.println();
}
I kinda understand why the first doesn't work, but I still want to know the optimal way to go about this.