-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
  • 122,468
  • 25
  • 185
  • 269
M.Dietz
  • 900
  • 10
  • 29

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
  • 55,782
  • 14
  • 81
  • 108
bit-shashank
  • 887
  • 11
  • 27