write some tests that exercise the Collections classes
create a project where you write 1 or 2 tests for each every one of these Collections classes. Figure out what the most common, most useful methods are, and use them in the test you write for the class. The class should be, say, TestHashMap, and then have a TestHasMap methid which uses the various methods you deem useful.
I've included two classes, Person
and Address
should you need a concrete class to supply to a generic structure. Feel free to use Integer
and/or String
as well.
- For the Set interface, HashSet is the most commonly used implementation.
- For the List interface, ArrayList is the most commonly used implementation.
- For the Map interface, HashMap is the most commonly used implementation.
- For the Queue interface, LinkedList is the most commonly used implementation.
- For the Deque interface, ArrayDeque is the most commonly used implementation.
Also include a test for Vector,TreeMap, Stack, TreeSet, Iterator, PriorityQueue and Comparable.
So 12 Test in all, make sure you use the methods that most commonly describe why the data structure exists; e.g. for Stack be sure to use pop, push, peek and isEmpty
.