(^532) | Array-Based Lists
myList
listItems[0]23
45
65
?
?
6
0
listItems[1]
listItems[numItems-1]
listItems[listItems.lenth-1]
numItems
currentPos
listItems
list
array
Figure 11.3 An Instance of Class List
publicList(int maxItems)
// Instantiates an empty list object with room for maxItems items
{
numItems = 0;
listItems = new String[maxItems];
currentPos = 0;
}
Should the class provide a default constructor? Let’s do so as a precaution.