Page 369 - AP Computer Science A, 7th edition
P. 369

 Chapter Summary
 Manipulation of one-dimensional arrays, two-dimensional arrays, and array lists should be second nature to you by now. Know the Java subset methods for the List<E> class. You must also know when these methods throw an IndexOutOfBoundsException and when an ArrayIndexOutOfBoundsException can occur.
When traversing an ArrayList:
• Use a for-each loop to access each element without changing it, or to modify each object in the list using a mutator method. • Use an Iterator to remove elements. (This is not in the AP
subset, but it is the easiest way to remove elements from an ArrayList.)
A matrix is an array of row arrays. The number of rows is mat.length. The number of columns is mat[0].length.
When traversing a matrix:
• Use a row-column traversal to access, modify, or replace
elements.
• Use a nested for loop to access or modify elements, but not
replace them.
• Know how to do row-by-row array processing if you have an
appropriate method that takes an array parameter.
MULTIPLE-CHOICE QUES TIONS ON ARRAYS AND ARRAYLISTS
  1. Which of the following correctly initializes an array arr to




















































































   367   368   369   370   371