JavaCollections

JavaCollections - Java Collections Professor Evan Korth...

Info iconThis preview shows pages 1–8. Sign up to view the full content.

View Full Document Right Arrow Icon
Java Collections Professor Evan Korth (adapted from Sun’s collections documentation)
Background image of page 1

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

View Full DocumentRight Arrow Icon
APIs and Versions Number one hint for programming with Java Collections: use the API http://java.sun.com/j2se/1.5.0/docs/api/java/util Be sure to use the 1.5.0 APIs to get the version with generics
Background image of page 2
Java Collections Framework The Java language API provides many of the data structures from this class for you. It defines a “collection” as “an object that represents a group of objects”. It defines a collections framework as “a unified architecture for representing and manipulating collections, allowing them to be manipulated independent of the details of their representation.”
Background image of page 3

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

View Full DocumentRight Arrow Icon
Collections Framework (cont) Collection Interfaces - Represent different types of collections, such as sets, lists and maps. These interfaces form the basis of the framework. General-purpose Implementations - Primary implementations of the collection interfaces. Legacy Implementations - The collection classes from earlier releases, Vector and Hashtable, have been retrofitted to implement the collection interfaces. Wrapper Implementations - Add functionality, such as synchronization, to other implementations. Convenience Implementations - High-performance "mini-implementations" of the collection interfaces. Abstract Implementations - Partial implementations of the collection interfaces to facilitate custom implementations. Algorithms - Static methods that perform useful functions on collections, such as sorting a list. Infrastructure - Interfaces that provide essential support for the collection interfaces. Array Utilities - Utility functions for arrays of primitives and reference objects. Not, strictly speaking, a part of the Collections Framework, this functionality is being added to the Java platform at the same time and relies on some of the same infrastructure.
Background image of page 4
Collection interfaces The core collection interfaces encapsulate different types of collections. They represent the abstract data types that are part of the collections framework. They are interfaces so they do not provide an implementation!
Background image of page 5

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

View Full DocumentRight Arrow Icon
public interface Collection<E> extends Iterable <E> Collection — the root of the collection hierarchy. A collection represents a group of objects known as its elements . The Collection interface is the least common denominator that all collections implement and is used to pass collections around and to manipulate them when maximum generality is desired. Some types of collections allow duplicate elements, and others do not. Some are ordered and others are unordered. The Java platform doesn't provide any direct implementations of this interface but provides implementations of more specific subinterfaces, such as Set and List.
Background image of page 6
public interface Collection<E> extends Iterable <E> public interface Collection<E> extends Iterable<E> { // Basic operations int size(); boolean isEmpty(); boolean contains(Object element); boolean add(E element);
Background image of page 7

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

View Full DocumentRight Arrow Icon
Image of page 8
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 05/06/2010 for the course COMPUTER S 101 taught by Professor Sanaodeh during the Spring '08 term at NYU.

Page1 / 30

JavaCollections - Java Collections Professor Evan Korth...

This preview shows document pages 1 - 8. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online