Chapter 7: Arrays and Array Lists
Today's Office Hours
I will have office hours today from 2:10 p.m. - 3:00 p.m. instead
of from 10:15 a.m. - 11:00 a.m. Thanks.
Enhanced for Loop
double [] data = ... ;
for (double element: data)
{
// process element
}
Common Algorithms
- Count the number of times something occurs.
- Determine if something is present.
- Find the maximum (or minimum).
2-D Arrays
- Declaration, e.g. char tictactoe [] [];
- Allocation, e.g. tictactoe = new char [3][3];
- Access, e.g. tictactoe[2][0];
- Assignment, e.g. tictactow[2][0] = 'x';
- Row Determination, e.g. tictactoe.length;
- Column Determination, e.g. tictactoe[0].length;
Lecture Code
This code adds functionality to the CardDeck and Card classes that we began
writing on Wednesday.
This code introduces the ArrayList class.