Abstract Data Types - Abstract Data Types An abstract data...

Info icon This preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
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:
Image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern