-1

I wanna generate 743 different "codes" which should follow the following syntax: A1,A2,...,A20,B1,B2... So I thought about doing it with two for-loops.

  • One that goes through every "row" which is A,B,C,...
  • and the second one that goes through every "column" which is 1-20.

Afterwards I wanna connect them and that's going to lead to one code which is "A1" for example.

My problem is the first loop, how do I do it that hes going to add an A at the first iteration, a B at the second iteration etc...

Pshemo
  • 118,400
  • 24
  • 176
  • 257
M.Dietz
  • 810
  • 6
  • 20

1 Answers1

0

It's simple: you just have to use a char datatype. Below is the complete code.

for(char ch='A';ch<='Z';ch++)
{
    for(int i=1;i<=20;i++)
    {
        System.out.println(ch+""+i); // this will concatenate ch and i
    }
}
khelwood
  • 52,115
  • 13
  • 74
  • 94
Lone_Coder
  • 857
  • 11
  • 25