Java Collections Framework Java Collections Framework: CS211 Fall 2000
Java Collections Framework Java Collections Framework: CS211 Fall 2000
Collections: holders that let you store and organize objects in useful ways for efficient access Since Java 1.2, the package java.util includes interfaces and classes for a general collection framework
Goal: conciseness q A few concepts that are broadly useful q Not an exhaustive set of useful concepts Two types of concepts are provided q Interfaces (i.e., ADTs) q Implementations
HashMap TreeMap
q q
Set Implementations
s
Set extends Collection q Set has no methods of its own, but it inherits the methods from Collection A Set contains no duplicates q If you attempt to add( ) an element twice then the second add( ) will return false (i.e., the Set has not changed)
Write a method that checks if a given word is within a Set of words Write a method that removes all words longer than 5 letters from a Set
s
s
s
8