Misconception: students sometimes struggle to identify where in a loop variable values get changed.

  • Example:
    • int[] a = {10, 20, 30, 40}; for(int i=0; i < a.length; i++){     a[i]= a[i]/a[0]; }
    • Students may think the following code produces the array [1, 2, 3, 4] instead of [1, 20, 30, 40]
      • This is because they may not make the connection between the changed value of a[0] after the loops first iteration and it’s subsequent impact on the rest of the loops iterations.

More about this tip

External Source
Interview with Rebecca Dovi