Try this:
public class Lab5_12A {
public static void main(String[] args) {
// Define variables and assign value
char character1 = 'A';
char character2 = 'Z';
int number = 0;
for (character1 = 'A'; character1 <= character2; character1++) {
System.out.printf(printChars(character1, character2, ++number) + " ");
}
}
private static String printChars(char ch1, char ch2, int numberPerLine) {
String result;
if (numberPerLine % 10==0) {
result =ch1+"\n";
}
else {
if(numberPerLine==1){
System.out.printf(" ");
result =""+ch1 ;
}
result = ch1+"";
}
return result;
}
}
I hope this will be help to you