Work through the list without notes. If you cannot do a statement, follow its link, then come back. Guide = study guide; Practice = practice questions; see also the revision notes.
Understanding
- I can explain that traversing an array means using repetition to access all or an ordered sequence of elements. (Guide: “Visiting every element”; Practice Question 1)
- I can explain why the standard loop test is i < a.length. (Guide: “The indexed for loop”; Practice Questions 1 and 9)
- I can explain that the enhanced for variable holds a copy of each element. (Guide: “The enhanced for loop”; Practice Question 3)
- I can explain why a mutator call on an element changes the object but assigning to the loop variable does not change the array. (Guide: “The enhanced for loop”; Practice Questions 4 and 8)
Skills
- I can write indexed for loops for forward, backward and stepped traversals. (Guide: “The indexed for loop”; Practice Questions 2 and 7)
- I can write a while loop that traverses an array, including one that stops early. (Guide: “The while loop” and Worked example 2; Practice Questions 5 and 7)
- I can rewrite an enhanced for loop as an indexed for loop and as a while loop. (Guide: “The enhanced for loop”; Practice Questions 6 and 7)
- I can trace a traversal with a table showing the index and the running value. (Guide: Worked example 1; Practice Questions 2, 5 and 7)
Reasoning
- I can decide when an enhanced for loop is suitable and when an indexed loop is needed. (Guide: Worked example 1; Practice Questions 6 and 7)
- I can find and fix off-by-one errors at both ends of a loop. (Guide: Worked example 2; Practice Question 9)
- I can predict an ArrayIndexOutOfBoundsException from a loop header. (Guide: Worked example 2, part (c); Practice Questions 1 and 9)
All ticked? Move on to the Topic 4.5 study guide, Implementing Array Algorithms, or return to the course roadmap.