for(inti = 1; i <= 1; i++) {//y-axis
for(int j = (char')A'; j <= (char')D'; j++) {//x-axis
System.out.print((char)j + " ");
}//inner
System.out.println();//Rewind Line
}//outer
for(inti = 1; i <= 1; i++) {//y-axis
for(int j = (char')E'; j <= (char')H'; j++) {//x-axis
System.out.print((char)j + " ");
}//inner
System.out.println();//Rewind Line
}//outer
for(inti = 1; i <= 1; i++) {//y-axis
for(int j = (char')I'; j <= (char')L'; j++) {//x-axis
System.out.print((char)j + " ");
}//inner
System.out.println();//Rewind Line
}//outer
}//main
}
Is there a way to reduce this more briefly?
Please help me because I can't get the answer.
java for
I don't know Java well, so there may be grammatical errors, but please look at the basic ideas.
for ( int j = (char)'A'; j <= (char)'L'; j++) {
System.out.print((char)j + "); // Do what you need to do for all indexes.
if (j == 'D' || j == 'H' || j == 'L') { // in a specific index
System.out.println(); // Do what you want to do.
}
}
© 2024 OneMinuteCode. All rights reserved.