posted 20 years ago
The Jxam asks if the following is valid:
int q;
for (int p = 0, q = 0; p < 5; p++){
System.out.println("Val = " + p + q);
}
The provided answer is: "Answer 4 is incorrect, because you can't mix the initialisation of a local loop variable declaration in the 'for' loop, with the initialisation of another loop variable."
I know that it is illegal to mix declarations/initializations in the first part of the for loop, BUT-- it seems to me that int p=0, q=0 is a valid declaration/initialization, therefore the q in the for statement is a seperate/different more local q? is that true?
jb.