This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: Abstract Data Types An abstract data type (ADT) is a specification of the set of operations that can be performed on the data stored by the ADT. An ADT is “abstract” in the sense that it is independent of a concrete implementation. In Java, an abstract data type is represented by an interface , which shows the methods and their arguments. Clients of an interface (this means other Java classes that use the interface) can be written and compiled using the interface only—it is not necessary for them to know about the implementation classes. Because the implementation is hidden, this means that the ADT can be implemented in various ways. As long as it adheres to the interface, user programs can remain the same. For example, the List ADT can be represented using the array-based implementation ArrayList or the linked-list implementation LinkedList . The separation of interfaces and implementations protects Java programs from design decisions that may change in the future. It makes it easier to maintain programs, and to reuse code (because the same code can now be used for different implementations). We will see many examples of this in the future. Java provides interfaces and implementations for many abstract data types. They are in the package java.util , and are known as the Collections Framework . Fig. 1 shows the main Collection interfaces in java.util . Collection Set List Queue SortedSet Deque Map SortedMap Figure 1: Java collection interfaces Map A map (also called a dictionary ) is an object that maps keys to values . A map supports two main operations: • insert a (key, value) pair,...
View Full Document
This note was uploaded on 04/20/2010 for the course CS CS206 taught by Professor Lee during the Fall '09 term at 카이스트, 한국과학기술원.
- Fall '09