Web Page Version of the Program

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

If the user sets the initial value to -2 and the limit value to 1 what values will be printed out?

Answer:

count is: -2
count is: -1
count is: 0
count is: 1

Zero is included in the list of values!

Web Page Version of the Program

You might enjoy playing with this JavaScript version of the program. Try a variety of initial and limit values. If the output does not fit into the text area, use the "scroll bar" on the right to move up and down through the output.


count =  ;

limit =  ;

while ( count <= limit ) 
{
  System.out.println( "count is:" + count );
  count = count + 1;
}
System.out.println( "Done with the loop" );
 

(The output window sometimes shows messages that would not be printed by the example code.)


QUESTION 11:

Try entering an initial value of 9 and a limit value of 4. What happens? Why?