Core Java| JSP| Servlets| XML| EJB| JEE5| Web Services| J2ME| Glossary| Questions?

 

 

 

 

 

 

 

 

 

 

 

 

 

Search Tutorials

Latest Questions
Comments
 
Collection Interfaces 
 

The Collections Framework is made up of a set of interfaces for storing and manipulating groups of data into a single unit.

 

Collection Interfaces

                         

The Collections Framework is made up of a set of interfaces  for storing and manipulating groups of data into a single unit. It consists of several interfaces, and classes that implement those interfaces, contained within the java.util package. It provides tools for maintaining a data container of objects. 

Different interfaces describe different types of functionalities.

The following diagrams shows the framework of core collection interfaces hierarchy.


Table of the ordered and unordered Collection interfaces shown as:

 Interface name  Ordered  Allows duplicates  Maps key to object
 Collection  No  Yes  No
 Set  No  No  No
 List  Yes  Yes  No
 Map  No  No  Yes
 SortedSet  Yes  No  No
 SortedMap  Yes  No  Yes

Collection Interface:

The Collection interface is the root interface for the Java collections hierarchy. It is extended by the List, Set, and the SortedSet interfaces. The Collection interface is used to represent a group of objects, or elements. Typically, it represents data items that form a natural group. Some collection allows duplicate elements while others do not. It consists of both ordered and unordered elements.

 The declaration of the Collection interface is shown as:

public interface Collection<E>.. 

The <E> syntax tells that, the declared interface is a generic interface i.e. when you declare a Collection instance you should specify the type of object contained in the collection.
This interface supports basic operations like adding and removing. When you try to remove an element, only a single instance of the element in the collection is removed, if it is available. 

Following methods can be used for adding and deleting an element respectively.

boolean add(Object element)      
boolean remove(Object element)

The list of other methods belonging to the Collection interface is shown in the table given below

Method

Uses

 add(E o)
    
  Adds the specified element to this set if it is not already present (optional operation).
         
 clear()   Removes all of the elements from this set (optional operation).
contains(Object o)  Returns true if this set contains the specified element.
 equals(Object o)   Compares the specified object with this set for equality.
 hashCode()   Returns the hash code value for this set.
  isEmpty()    Returns true if this set contains no elements.
 iterator()   Returns an iterator over the elements in this set.
 remove(Object o)   Removes the specified element from this set if it is present (optional operation).
 size()   Returns the number of elements in this set (its cardinality).

                         

» View all related tutorials
Related Tags: c algorithm api ide collections orm ant data form interface framework software io multiple ip order vi collection tag int

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

1 comments so far (
post your own) View All Comments Latest 10 Comments:

yeh,i understand some concepts from this tutorial,really it is helpedme alot......

Posted by raj on Monday, 11.12.07 @ 14:21pm | #36953

Training Courses
Tell A Friend
Your Friend Name
Software Solutions
Least Viewed
Most Rated
Recently Viewed
Search Tutorials

 

 
 

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

Indian Software Development Company | iPhone Development Company in India | Flex Development Company in India | Java Training Delhi | Java Training at Noida |

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

Copyright © 2008. All rights reserved.