FAQ
Java Tutorial
Questions by Topic
Mock Exam 1
Mock Exam 2
Exam Simulator
Online Java Training
Other Certification sites
Certification Tips
Exam Objectives
About JavaPrepare
Books
Certification Books
SCEA Books
Online Books
Tutorial Topics
Language Fundamentals
Operator and Assignments
Declaration and Access Control
Classes in Java
Threads
Collections
Files
Advertisements

 
javaprepare.com
your tool for Java Certification
home | tutorial | questions | test 1

Collections

Collections
A Collection allows a group of objects to be treated as a single unit. Collections define a set of core interfaces. These are -
  • Collection
  • Set
  • List
  • SortedSet
  • Map
  • SortedMap

Collections also provide implementation for these interfaces.


Core Interfaces
The Object hierarchy of Core Interfaces defined in Collections is given below.
Figure: Core Interfaces of Collections

Collection Interface
The Collection interface is the root of Collection hierarchy, and is used for common functionality across all collections. There is no direct implementation of Collection interface.

Set Interface
The Set interface is used to represent a group of unique elements. It extends the Collection interface. The class HashSet implements the Set interface.

SortedSet Interface
The SortedSet interface extends the Set interface. It provides extra functionality of keeping the elements sorted. So SortedSet interface is used to represent collections consisting of unique, sorted elements. The class TreeSet is an implementation of interface SortedSet.

List Interface
The list interface extends the Collection interface to represent sequence of numbers in a fixed order. Classes ArrayList, Vector and LinkedList are implementation of List interface.

Map Interface
The Map Interface is a basic interface that is used to represent mapping of keys to values. Classes HashMap and Hashtable are implementations of Map interface.

SortedMap Interface
The SortedMap Interface extends Map interface and maintains their mappings in key order. The class TreeMap implements SortedMap interface.

The table below gives the list of Collection interfaces and the classes that implement them.
Interface Class Implementation
Set HashSet
SortedSet TreeSet
List ArrayList, Vector, LinkedList
Map HashMap, Hashtable
SortedMap TreeMap

home | tutorial | questions | test 1