Misconception: Students think that arrays start at 1 instead of 0.

Like(1944 Likes)

Goal:

  • Have students understand that array indices start at 0.

Reason:

  • Students are often accustomed to counting from 1, and need to be reminded to count from 0 when finding an array element's index.

Action:

  • Specifically point out this difference to students.
    • In the array [1, 5, 10, 7, 9], the 3rd element is 10 but the element at index 3 is 7.
  • Walk through figuring out an element's index (counting up from the very first element, at index 0) every time you refer to an element.
  • Consistently refer to array elements by their index, rather than switching between using "the element at index 3" and "the fourth element."
  • Remind students that the array's last index will be one less than its length.

More about this tip

External Source

Leigh Ann Sudol-DeLyser’s notes from 2009 AP CS A exam. Interview with Michael Lee.

Interview with Michael Lee