go to previous page   go to home page   go to next page hear noise highlighting

Answer:

Yes. (Actually, a good answer would be "sounds dangerous", because it is.)


Omitting the Test

When the test part of a for is omitted it is as if the value true were put in its place. So,

for ( initialize ;   ; change )
  loopBody ;

is the same as:

for ( initialize ;  true  ; change )
  loopBody ;

This is done for compatibility with the language C. It should not be used in newly written programs.

Several syntactic oddities were included in Java so that it would look familiar to C programmers.


QUESTION 14:

Could all three parts be omitted from a for?


go to previous page   go to home page   go to next page