Misconception: Students think about the conditions of while loops as telling the program when to stop rather than telling the computer when to continue.

  • Emphasize to students that the condition of a while loop tells the program when to continue. This is important to help students build correct mental models regarding how code is interpreted.
    • For example, in the following Java code, the program will continue as long as x is greater than 0.
      • while ( x > 0 ) {
          System.out.println( “Hi!” ); x--;
External Source: 
Interview with Helen Hu.
Other Tips By: