Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Spring Framework | Web Services | BioInformatics | Java Server Faces | Jboss 3.0 tutorial | Hibernate 3.0 | XML
 
 
Hot Web Programming Job

 

Tutorial Categories: Ajax | Articles | JSP | Bioinformatics | Database | Free Books | Hibernate | J2EE | J2ME | Java | JavaScript | JDBC | JMS | Linux | MS Technology | PHP | RMI | Web-Services | Servlets | Struts | UML

[an error occurred while processing this directive]

Java Notes

Collections Overview

[an error occurred while processing this directive]

Summary of Collections interfaces

Most of the methods in the data structure classes are those of the interfaces that the classes implement.

  • Collections - This is a basic set of methods for working with data structures.
  • List - (extends Collection) Elements are accessible sequentially.
  • Map - Stores key/value pairs, rapidly accessible by key.
  • SortedMap - (extends Map) As with map, but can be also be accessed in order.
  • Set - (extends Collection) For a given key there is only one value.
  • SortedSet - (extends Set) As above, but can also be accessed in order.

Class/Interface Hierarchy

The following classes and interfaces, are in the java.util package. Indentation shows the class inheritance. The most useful classes are in bold.

Collections  // Contains may useful static methods.

AbstractCollection<E> implements Collection<E>, Iterable<E>
    AbstractList<E> implements List<E>
        ArrayList<E> implements RandomAccess
        AbstractSequentialList<E>
            LinkedList<E>
        Vector<E> implements RandomAccess<E>  // Synchronized equivalent of ArrayList
            Stack<E>  // Adds push(), pop(), and peek()
    AbstractSet<E> implements Set<E>
        HashSet<E>
            LinkedHashSet<E>
        TreeSet<E> implements SortedSet<E>
        EnumSet<E>   // Bitset implementation for Enum class.
    AbstractQueue<E> implements Queue<E>
        PriorityQueue<E>
    
AbstractMap<K, V> implements Map<K, V>
    HashMap<K, V>
        LinkedHashMap<K, V> // Keys can be iterated in insertion order.
    TreeMap<K, V> implements SortedMap<K, V>
    EnumMap<K, V>          // Keys must be from same Enum class.
    WeakHashMap<K, V>      // Special usage - Keys are weak references.
    IdentityHashMap<K, V>  // Special usage - Keys must be identical.
    
Map.Entry<K, V>       // Map key/value pair.
    
Iterator<E>           // Interface requires hasNext(), next(), ?remove()
    ListIterator<E>   // Interface
    
Comparator<T>         // Interface requires compare() and equals()

// The following java.lang interfaces are commonly used in Collections.
Iterable<T>          // Interface requires iterator()
Comparable<T>        // Interface requires compareTo()

Concrete classes and interfaces

These are some of the most useful data structure classes, listing the primary data-structure relevant interface, and omitting utility interfaces such as Cloneable and Serializable.

Class Implementation
Most commonly used classes
ArrayList Sequence of values stored in resizable array
LinkedListSequence of values stored in linked list
HashMap Key/value pairs in hash table.
TreeMap Key/value pairs in balanced binary tree.
HashSet Single copy of value stored in hash table. Implements Set.
TreeSet Single copy of value stored in balanced binary. Implements Set.
Interfaces
CollectionMethods common to all data structures.
List Basic List methods. Implemented by ArrayList and LinkedList.
Map Basic Map methods. Implemented by HashMap and TreeMap.
Map.Entry Key/value pairs in Set returned by Map.entrySet().
Set Basic Set methods. Implemented by HashSet and TreeSet.
Iterator Methods for forward iteration.
ListIteratorAdditional methods for going backward.
Specialized classes
BitSet Expandable array of bits.
LinkedHashSetHash table where entries can also be accessed in order of creation.
WeakHashMapHash table using weak references
PreferencesFor persistent storage of program options.
Properties Pre-Java 2, compare to Preferences
Older classes which have a newer replacement
HashTable Older, synchronized version of HashMap.
Vector Older, synchronized version of ArrayList, still used.
Obsolete classes
Dictionary Obsolete abstract class. Do not use.

Interface Implementations

Implementations
InterfaceArrayBalanced TreeLinked ListHash table
ListArrayList LinkedList 
Map   TreeMap  HashMap
Set   TreeSet  HashSet

Algorithm and Data Structure Links

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 

Current Comments

0 comments so far (
post your own) View All Comments Latest 10 Comments:
  JDO Tutorials
  EAI Articles
  Struts Tutorials
  Java Tutorials
  Java Certification

Tell A Friend
Your Friend Name
Search Tutorials

 

 
 
Browse all Java Tutorials
Java JSP Struts Servlets Hibernate XML
Ajax JDBC EJB MySQL JavaScript JSF
Maven2 Tutorial JEE5 Tutorial Java Threading Tutorial Photoshop Tutorials Linux Technology
Technology Revolutions Eclipse Spring Tutorial Bioinformatics Tutorials Tools SQL
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2007. All rights reserved.