Omitting the change

Classic programmed-learning exercises, refreshed for modern Java and presented in the current MrStyner.com portfolio style.

Modern Java noteThis archive has been refreshed for Java 25 LTS. Core language concepts remain useful, while outdated setup instructions and browser-era Java are labeled or replaced. Java 26 is the current feature release; Java 25 is used here as the stable teaching baseline.
go to previous page   go to home page   hear noise   go to next page

Answer:

Yes.

Omitting the change

Syntactically you can omit the change part. This means that if the Java compiler sees:

for ( count = 0; count < 25;  )

it will not complain. It is now your responsibility to put statements that make a change somewhere into the loop body. For example:

for ( count = 0; count < 25;  )
{
  System.out.println("count is: " + count );
  count = count + 1;
}

would work fine. (Although in this case it would be far better to do the change in the for.)

QUESTION 12:

Can a for statement be used to implement a sentinel controlled loop?