lec04 - CSE 12 The Java Collections Framework The Java...

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

View Full Document Right Arrow Icon
04 The Java Collections Framework The Collection and List Interfaces Ambiguities in Interface Specification CSE 12 The Java Collections Framework
Background image of page 1

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

View Full DocumentRight Arrow Icon
Data structures, collections, containers A data structure is. .. an object that contains data Another word for a data structure is a “collection” or “container” Different programming language libraries provide various data structures that can be used by application programmers In Java, this library is called the Java Collections Framework (JCF) The JCF is a collection of interfaces, abstract and concrete classes providing a standard set of collection (container) types, in the java.util package
Background image of page 2
Iterable Interfaces in JCF
Background image of page 3

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

View Full DocumentRight Arrow Icon
List implementations in JCF
Background image of page 4
The Collection<E> interface A very important interface in the JCF is Collection<E> We will look at the Javadoc documentation of this interface • Collection<E> specifies 15 instance methods which cover most general-purpose data structure operations So, a class declaring itself to implement Collection<E> must provide definitions for all the methods, or it will not compile However, in the documentation of Collection<E> , some of these methods are listed as “optional operations”. .. Question: What do all the optional operations have in common?
Background image of page 5

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

View Full DocumentRight Arrow Icon
The Collection<E> interface java.util Interface Collection<E> All Superinterfaces: Iterable <E> All Known Subinterfaces: BeanContext , BeanContextServices , BlockingDeque <E>, BlockingQueue <E>, Deque <E>, List <E>, NavigableSet <E>, Queue <E>, Set <E>, SortedSet <E> All Known Implementing Classes: AbstractCollection , AbstractList , AbstractQueue , AbstractSequentialList , Abstr actSet , ArrayBlockingQueue , ArrayDeque , ArrayList , AttributeList , BeanConte xtServicesSupport , BeanContextSupport , ConcurrentLinkedQueue , ConcurrentS kipListSet , CopyOnWriteArrayList , CopyOnWriteArraySet , DelayQueue , Enum Set , HashSet , JobStateReasons , LinkedBlockingDeque , LinkedBlockingQueue , LinkedHashSet , LinkedList , PriorityBlockingQueue , PriorityQueue , RoleList , R oleUnresolvedList , Stack , SynchronousQueue , TreeSet , Vector
Background image of page 6
Collection<E> interface description public interface Collection<E> extends Iterable <E> The root interface in the collection hierarchy . A collection represents a group of objects, known as its elements . Some collections allow duplicate elements and others do not. Some are ordered and others unordered. The "destructive" methods contained in this interface, that is, the methods that modify the collection on which they operate, are specified to throw UnsupportedOperationException if this collection does not support the operation. Some collection implementations have restrictions on the elements that they
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 03/27/2012 for the course CSE 12 taught by Professor Gary during the Fall '08 term at UCSD.

Page1 / 24

lec04 - CSE 12 The Java Collections Framework The Java...

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