Misconception: Students believe that while loops tell the program when to stop rather than when to continue.

  • Emphasize to students that the condition of a while loop tells the program when to continue. 
  • Explain that "While (this) is true" is the same as "Until (this) is false." For example, "while school is in session." is equivalent to "until school ends." Additionally, in the following Java code, the program will continue as long as x is greater than 0, or until x is less than or equal to 0.
    • while ( x > 0 ) {
      • System.out.println( "Hi!" );
      • x--;
    • }

More about this tip

External Source

Interview with Michelle Friend

Interview with Helen Hu