Collection Coding Exercise
The goal of today's lab is to practice implementing type-safe
collections in Java.
Completing the Sack Class
- Download and complete Sack.java. Your
implementation should use an
ArrayList
for data storage. Create a
driver class so that you can test methods as you write them.
- Modify your
Sack
class so that it type-safe (uses generics) and
update your driver to test the new version of your class.
- Submit both the completed
Sack
class and driver.
If you Have Extra Time
- Create a new class named
HashSack
that implements the same set of methods using a HashMap
for data storage. Modify your driver to test this new class.
- Add code to the driver that illustrates the performance differences between
Sack.java
and HashSack.java
.