I am doing an execise in a book and there is a part of the code that I don't understand. To my undrstanding, a for loop always has three parts, initialization, condition, and iteration. Yet, in the code below, the for loop has none of the three. The code is written as follows "for(,,){" Although it does have two commas which makes me guess that the three parts are left blank, I still do not understand how any comparison, initialization or iteration is done without any values. Please explaine to me how the loop works with the parts left blank. the code is below. I did not include any of the class definentions only the method calls. I put the code in question in bold and Italcs.
Thanks,
Kevin Haynes
Code:
class HelpClassDemo {
public static void main(String args[])
throws java.io.IOException {
char choice, ignore;
Help hlpobj = new Help();
for(;;) {
do {
hlpobj.showmenu();
choice = (char) System.in.read();
do {
ignore = (char) System.in.read();
} while(ignore != '\n');
} while( !hlpobj.isvalid(choice) );
if(choice == 'q') break;
System.out.println("\n");
hlpobj.helpon(choice);
}
}
}