Assign ASCII character AZ in the list
5 answers
In Unicode (used with Java strings), the characters A through Z produce a contiguous sequence, so using a loop is possible. "A", however, is not the first character in Unicode. This can be done in a general way, without assuming character codes, and simply assuming that there is a sequence from A to Z with no other codes in between.
char values[] = new char['Z'-'A'];
int i = 0;
for (char c='A'; c<='Z'; c++)
values[i++] = c;
+1
source to share