Do you know collection classes in Java?

Share post:

Do you know collection classes in Java?

Quick Answer:

Collection is the way to store multiple items in a single unit.

The Collection is the base interface.

  • java.util.Collection is the root interface. -->Contains methods size(), iterator(), add() etc.
  • java.util.List, 
    • Can contain duplicate elements
  • java.util.Set
    • Cannot contain duplicate elements, Cannot do random access.
  • java.util.Queue
  • java.util.Map doesn't inherit from the Collection interface

Implementation classes:

  • ArrayList
  • LinkedList
  • HashMap, TreeMap
  • HashSet, TreeSet
HashSet TreeSet
Implementation of the set interface backed by a Hashmap      
no guarantee for iteration  order of the set and permits the Null element  
   

    

Relevant tags:

#java

Smashplus

Insights

Share post: