The Artima Developer Community
Sponsored Link

Java Buzz Forum
Collection interface in java

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
instanceof java

Posts: 576
Nickname: instanceof
Registered: Jan, 2015

instanceof java is a java related one.
Collection interface in java Posted: Sep 19, 2015 3:12 PM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by instanceof java.
Original Post: Collection interface in java
Feed Title: Instance Of Java
Feed URL: http://feeds.feedburner.com/blogspot/TXghwE
Feed Description: Instance of Java. A place where you can learn java in simple way each and every topic covered with many points and sample programs.
Latest Java Buzz Posts
Latest Java Buzz Posts by instanceof java
Latest Posts From Instance Of Java

Advertisement

  • Collection is the main interface.
  • There are many methods declared in Collection interface. These are the common methods for all collections to perform different operations.



  1. public interface Collection<E>
  2. extends Iterable<E>


    Methods in Collection Interface:

     1.public Boolean add(Object obj)
    •  Used to add element in to the collection

     2.public Boolean addAll(Collection c)

    • Adds all the elements of c to the invoking collection. Returns true if the operation succeeded else returns false.

     3.public boolean isEmpty()
    • Returns true if collection is empty otherwise returns false.

     4.public boolean remove(Object obj)
    • Remove element from collection. Returns true if successful deletion.

    5.public boolean  removeAll(Collection c)
    • Removes all elements of a collection.

     6.public void clear()
    • Deletes total elements from collection

     7.public boolean contains(Object obj)
    • This method used to search an element

     8.public boolean containsAll(Collection c)
    • This method used to search an element in a collection

     9.public boolean retianAll(Collection c)
    • Used to delete all elements from a collection except specified one.

    10.public int size()
    • Returns total numbers of elements in a collection

    11.public Iterator iterator()
    • Returns iterator for the collection

    12.public boolean equals(Object obj)
    • Compares two collections

    13.public int hashCode()
    • Returns hashcode

    14.public Object[] toArray()
    • This method used to convert collection into array
    15.public Object[] toArray(Object[] obj)
    • Returns an array containing only those collection elements whose type matches that of array.

    Difference Between Collection and Collections:

    • Collection is the base interface for most of the classes.
    • Collections is the utility class.


    Read: Collection interface in java

    Topic: Grails tutorial for beginners Previous Topic   Next Topic Topic: Pulse Admin UI Updates

    Sponsored Links



    Google
      Web Artima.com   

    Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use