Java Collections Framework Take 2

last updated 4/27/07

 

Java Class Library

import java.util.*;

In this package you will find a number of common data structures already implemented for you.

The framework includes

 

 

 

 


Differing properties of the various collections

Similar properties Differing properties
  • a collections' size can grow dynamically
  • defined to hold Objects
  • uses references rather than copies (shallow copying)
  • provides two constructors, one to be empty, other to be a copy of the contents of another collection (not necessarily of the same structure)
  • logical structure of the elements
  • underlying implementation
  • efficiency of the operations
  • set of supported operations
  • duplicate entries may or may not be permitted
  • support of "keys"
  • whether or not elements are "sorted"

 

 


Class and Interface Hierarchy

Figure is scanned from Java Programming Advanced Topics, J. Wigglesworth and P. Lumby, 2000 Course Technology, page 395

 

 


Exploring the Collections Framework

In another browser window, go to the following official Sun JavaDoc site  http://java.sun.com/j2se/1.5.0/docs/api/

 Click on the java.util package and answer the following questions

1. In the above drawing

2. What data structures that we studied in CS 2 seem to be missing from the framework?

3. Does every concrete class implement an interface, directly or indirectly?

4. Consider the Set Interface. 

5. Does the Set Interface fully mimic the mathematical set concept? Why or why not?

6. What are the performance expectations of the TreeMap operations?

7. Consider the Hashtable class.

8.  How is the HashSet class different from the Hashtable?

9. How is the WeakHashMap different from the HashMap?

10. What is the LinkedList in the LinkedHashMap providing? Is the underlying implementation chaining?

11. How many methods are available in the Stack class?  What is the likely underlying data structure to implement the stack (Array or linked list)?

12. How would you implement a queue structure with the LinkedList class? What methods support the abstract queue operations?

13. The class Arrays provides a set of static algorithms operable on arrays.  What are the polymorphic groups (groups of methods with the same name)? What code would you use to sort your array and execute the binary search in your final project?

14. The Iterator and ListIterator interfaces provide a mechanism to step through the elements of a collection.

15. What miscellaneous classes, finally, are found in the java.util package?