Start by having students transpose code from one loop type to the other when teaching all the different conditionals for the AP CS A exam.

  • Specifically, you may want to teach whole loops before for loops so that for loops can be explained as a condensed while loop that uses a counter.
    • When students do progress to for loops, have students convert while loops into for loops so they can see the similarities between the two structures. For example, have students convert the following while loop on the left, to the corresponding for loop on the right. 
int count = 1; while(count ≤ 10){ System.out.println(count); count++; } for(int count = 1; count ≤ 10; count++) { System.out.println(count); }
  • Ask students, "What would you change?"
    • Even though the syntax is quite different for different types of loops, you don’t have to change much when transposing (especially between while and do while).
  • Transposing loops is often the easiest first problem.
  • It also shows an underlying understanding of loops structure.

More about this tip

External Source

Interview with Dani McAvoy, Interview with Dan Leyzberg, Interview with Joon Kim