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

Collection Interface

The Collection interface is the parent of the List and Set interfaces, but not Map.

Assume the following declaration for identifiers in the table below:

Collection coll; boolean b; Object obj; int i; Iterator it;
ReturnsMethodAction
Adding objects to a collection
b = coll.add(obj) Adds obj to this collection. Returns true if the collection was changed because of the add (eg, it will always be true for adding to a List, but will be false when adding to a Set that already contains this object).
b = coll.addAll(coll) Adds all elements of obj to this collection. Returns true if the collection was changed because of the addition.
Removing objects from a collection
 coll.clear() Removes all elements from the collection.
b = coll.remove(obj) Removes one occurrence of obj from this collection. Returns true if the collection was changed because of this operation.
b = coll.removeAll(coll) Removes all elements of coll from this collection. Returns true if the collection was changed because of this operation.
b = coll.retainAll(coll) Removes all elements of which are not in coll from this collection. Returns true if the collection was changed because of this operation.
Testing for presence in a collection
b = coll.contains(obj) Returns true if obj is in this collection.
b = coll.containsAll(coll) Returns true if all the members of coll are in this collection.
b = coll.isEmpty() Returns true if there are no objects in this collection.
Other
it = coll.iterator() Returns an iterator for this collection. The order of elements is only specified if the underlying collection has an ordering (eg, List and TreeSet so, HashSet doesn't).
i = coll.size() Returns the number of objects in this collection.
Object[] = coll.toArray() Returns an array containing the elements of this collection.
Object[] = coll.toArray(Object[]) Returns an array containing the elements of this collection.
Facing Programming Problem?
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:

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

 

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.

  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.