posted 22 years ago
So the comma separator is acceptable to separate expressions in the FOR loop. And they say that expressions and variable declarations cannot be mixed. My question is this. Can only expressions be separated in this init part of the for loop
Example
I know this can be done.
int j = 1, k;
for (j = 3, k = 6; j + k < 20; k += 2)
{
System.out.println("j = " + j);
}
What else can be mixed in the init part of the for loop? Is that it? The way they put the wording in the book, it sounds as if I can either do expression separation or init separation, but it seems I can't.
for (int j = 2, int k = 2; j + k < 20; k += 2)
{
System.out.println("j = " + j);
}
Can anyone clear up what EXACTLY can be done with the comma
Regards,
Dale
------------------
By failing to prepare, you are preparing to fail.
Benjamin Franklin (1706 - 1790)
By failing to prepare, you are preparing to fail.<br />Benjamin Franklin (1706 - 1790)