9.8 Programming Activity 2: Working with the ArrayList Class

In this activity, you will work with an ArrayList object. Specifically, you will write the code to perform the following operations:

  1. Fill the ArrayList object with Auto elements.

  2. Print the Auto elements contained in the ArrayList object.

  3. Set the model instance variable of every Auto element in the ArrayList object to a specified model.

  4. Find the maximum number of miles of all Auto elements contained in the ArrayList object.

  5. Count the number of Auto elements in the ArrayList with a specified model.

Table 9.6 provides the API for the Auto class.

TABLE 9.6 Constructors and Some Methods of the Auto Class

Auto Class Constructor Summary

Auto( )

  • creates an Auto object with ...

Get Java Illuminated, 5th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.