Collections Practice

Introduction

Collection classes are important in every object-oriented language, and Java has a sophisticated and powerful collections library, called the Java Collections Framework. Every Java programmer needs to be familiar with this framework.

Acknowledgements

This lab is based on labs created by Dr. Chris Fox and Dr. Nathan Sprague.

Exercise

Your goal in this lab is to complete the unfinished methods in CollectionExercises.java. For each method, you should first take a minute to think about the problem in order to select an appropriate collection type (or types) to use in your solution. The following JavaDocs may be helpful:

You should take full advantage of the functionality provided by the collection classes to make your solutions as concise and efficient as possible. For example, the Collection interface provides an addAll method that makes it possible to add all of the elements of one collection to another collection with a single instruction. Where appropriate, you should use that method rather than creating a loop that repeatedly calls the add method.

Your solutions for these exercises must satisfy the following requirements:

Submitting

You will submit your completed file through Canvas. You may submit as many times as you like.

Here is the test file to make sure your code is working: ZCollectionExercisesTest.java. Execute the tests locally one at a time using incremental development to make sure you are understanding. Feel free to comment out certain tests as you are working and to ask the instructor or TAs if you have any questions.