Hi, I merge some code in Thinking in Java as below: //: c03:ListCharacters.java // Demonstrates "for" loop by listing // all the ASCII characters. ///:~ The book states the syntax for for-loop: for(initialization; Boolean-expression; step) statement Is anything wrong in my code? Thanks.
[This message has been edited by Marilyn deQueiroz (edited August 14, 2001).]
You can initialize more than one variable, but they need to be of the same type (you can only pick ONE type). The clue that Marilyn was trying to give you is that the semi-colon is required to end one primitive type declaration, before beginning another. char c ; //notice the semi-colon int i, j; // two of the same followed by a semi-colon In the init portion of the for loop you only get ONE semi-colon, then you are in the next portion of the statement. Therefore only ONE primitive type declaration.
"JavaRanch, where the deer and the Certified play" - David O'Meara