Hi just wondering what this line of code means...
I have come across this code and dont quite understand what it does.. is anyone able to help me.
boolean letters[] =newboolean['Z' -'A' + 1];
for (char i ='A'; i <'Z'; ++i)
{
letters[i -'A'] =false;
}
Thanx heaps for your help guys
[674 byte] By [
wicksya] at [2007-10-2 20:58:47]

'Z' and 'A' are converted into unicode ints before the math is performed. Therefore the first line creates 90 - 65 + 1 = 26 booleans in an array.
The loop then goes through each char and sets its corresponding index (starting with 65-65) to false.
if i'm not wrong i think the code has a one-off bug, since the array has 26 elements but the loop runs only 25 times.
Also since the booleans are given a default of false, there isn't really a need to "initialize" the array to false.
That code just fills an array of boolean values. The for-loop is not necessary because boolean letters[] = new boolean['Z' - 'A' + 1]; by default fills the array with false-values
Every char has a numerical value, see:
http://www.cdrummond.qc.ca/cegep/informat/Professeurs/Alain/files/ascii.htm
So 'Z' - 'A' + 1 is the same as 90 - 65 + 1.