SlideShare a Scribd company logo
1 of 28
Collection Framework

        Ankit Kumar Garg




                
Introduction to collections

    
        a Collection is a container of Objects, it groups 
        many Objects into a single one
    
        Arrays are too static (but can be also 
        considered to be collections)
    
        Arrays have very few built­in features
    
        Originally, Java contained a few collection 
        classes, like Vector, Hashtable etc.
                                 

        Java 1.2 introduced the Collections Framework
    
        Another example of a collections framework is 
        the STL(Standard Template Library) in C++.




                               
What is a Collections Framework

    
        The Java Collections Framework consists of:
    
        Interfaces  –  abstract  data  types  representing  various 
        collections.  Allow  collections  to  be      manipulated 
        independently of their implementations.
    
        Implementations  –  these  are  the  concrete 
        implementations of the interfaces. They are reusable data 
        structures.


                                     

        Algorithms  –  these  are  able  to  perform  useful 
        computations,  like  searching  and  sorting,  on  the 
        implementations  of  the  interfaces.  So,  the  algorithms  are 
        polymorphic and therefore are reusable functionality.




                                       
Benefits of Collections

    
        Reduces programming effort
    
        Increases program speed and quality
    
        Allows interoperability among unrelated APIs 
    
        Reduces effort to design new APIs
    
        Helps to reuse the code



                               
Interfaces

    Here are the core Collections interfaces:




    Note: Collection is at the root, Map is separate
    All  Collections  interfaces  and  implementation 
      classes reside in the java.util package.
                              
Collection interface

    
        add(...) ­ adds an element
    
        contains(...) ­ checks if the specified element 
        exists
    
        remove(...) ­ removes an element
    
        clear() ­ removes all elements
    
        size() ­ returns the number of elements
    
         toArray() ­ converts the Collection to an array 
                                 
        etc.
Java Collection Classes




                
Map classes




          
Confusing words

    
        collection (lowercase ‘c’),  which represents any of 
        the data structures in which objects are stored and iterated 
        over.
    
        Collection  (capital  ‘C’),  which  is  actually  the 
        java.util.Collection  interface  from  which  Set  and  List 
        extend.
    
        Collections (capital ‘C’ and ends with ‘s’), 
        which is actually the java.util.Collections class that holds a 
        pile of static utility methods for use with collections.
                                      
java.util.List

    
        A List is a ordered collection of objects
    
        Implemented by ArrayList, Vector & LinkedList
    
        Users have control on where in List, new 
        element in the list should be added
    
        List can contain duplicates element



                                 
ArrayList

    
         It is an growable array. It gives you fast 
        iteration and fast random access.
    
        Adding element require O(n) time.
    
        ArrayList is not synchronized 
    
        Choose it when you need fast iteration but 
        aren’t as likely to be doing a lot of insertion and 
        deletion.
                                 
     
Vector

    
        Vector is a holdover from the earliest days of 
        Java
    
        A Vector is basically the same as an ArrayList, 
        but Vector() methods are synchronized for 
        thread safety.




                                
LinkedList

    
        Doubly Linked List implementation of List 
        Interface
    
        provide special method to get , remove and 
        insert element at the beginning and at the  end 
        of List
    
        Very efficient  for sequential access  and 
        insertion of element in the middle of the List 

                                 
     
java.util.Set

    
        A Set is a collection that does not contain any 
        duplicate element.
    
        Element that are put in  a set must override 
        equals() method to establish uniqueness




                                
HashSet
 
     It is an unsorted, unordered Set
 
     A Set BackedUp by HashMap
 
     can contain null
 
     basic operation take constant time
 
     Iteration order may not always be same
 
     Choose set where lookup time has to be 
     optimized
 
     Operations are not synchronized
                            
HashMap




        
LinkedHashSet

    
        It is an ordered version of HashSet
    
        It maintains a doubly­linked List across all 
        elements.
    
        can contain null
    
        Use it instead of HashSet when you care about 
        the iteration order


                                 
     
TreeSet

 
     It is guaranteed to be in ascending order, sorted 
     by the natural order of the element or by the 
     comparator provided.
 
     It uses a Red­Black tree structure
 
     can't contain null
 
     User defined class must implement comparable 
     interface
 
     It is not synchronized    
Map interface

    
        Map maps keys to values
    
        Used to lookup object based on key
    
        Doesn't extend Collection, but provides similar 
        methods
    
        – put(), get(), remove() operate with single key­value pairs
    
        – containsKey(), containsValue() check for existense
    
        – Collection views: keySet(), values(), entrySet()

                                        
java.util.HashMap

    
        Implementation is based on Hashtable
    
        Ideal for fast lookup
    
        Provide constant time performance for inserting 
        & locating pair
    
        Allows one null key in a collection and multiple 
        null values in a collection


                                 
java.util.Hashtable

    
        Hashtable is the synchronized counterpart to 
        HashMap.
    
        HashMap lets you have null values as well as 
        one null key, a Hashtable doesn’t let you have 
        anything that’s null.




                               
java.util.LinkedHashMap

    
        It maintains insertion order
    
        it will be somewhat slower than HashMap for 
        adding and removing elements
    
        you can expect faster iteration with a 
        LinkedHashMap




                                
java.util.TreeMap

    
        Implemented based on Red­Black tree
    
        The keys appear sorted
    
        Basic operation take log(n) time
    
        Methods are not synchronized




                               

More Related Content

What's hot

collection framework in java
collection framework in javacollection framework in java
collection framework in javaMANOJ KUMAR
 
5 collection framework
5 collection framework5 collection framework
5 collection frameworkMinal Maniar
 
Collections - Maps
Collections - Maps Collections - Maps
Collections - Maps Hitesh-Java
 
Collections - Lists, Sets
Collections - Lists, Sets Collections - Lists, Sets
Collections - Lists, Sets Hitesh-Java
 
Java collections concept
Java collections conceptJava collections concept
Java collections conceptkumar gaurav
 
Java ArrayList Tutorial | Edureka
Java ArrayList Tutorial | EdurekaJava ArrayList Tutorial | Edureka
Java ArrayList Tutorial | EdurekaEdureka!
 
Java Collections | Collections Framework in Java | Java Tutorial For Beginner...
Java Collections | Collections Framework in Java | Java Tutorial For Beginner...Java Collections | Collections Framework in Java | Java Tutorial For Beginner...
Java Collections | Collections Framework in Java | Java Tutorial For Beginner...Edureka!
 
Collections In Java
Collections In JavaCollections In Java
Collections In JavaBinoj T E
 
20.3 Java encapsulation
20.3 Java encapsulation20.3 Java encapsulation
20.3 Java encapsulationIntro C# Book
 
Java 8 Stream API. A different way to process collections.
Java 8 Stream API. A different way to process collections.Java 8 Stream API. A different way to process collections.
Java 8 Stream API. A different way to process collections.David Gómez García
 
Collections in Java
Collections in JavaCollections in Java
Collections in JavaKhasim Cise
 
Java exception handling
Java exception handlingJava exception handling
Java exception handlingBHUVIJAYAVELU
 

What's hot (20)

collection framework in java
collection framework in javacollection framework in java
collection framework in java
 
5 collection framework
5 collection framework5 collection framework
5 collection framework
 
Collections - Maps
Collections - Maps Collections - Maps
Collections - Maps
 
07 java collection
07 java collection07 java collection
07 java collection
 
Collections - Lists, Sets
Collections - Lists, Sets Collections - Lists, Sets
Collections - Lists, Sets
 
Java collections concept
Java collections conceptJava collections concept
Java collections concept
 
Java ArrayList Tutorial | Edureka
Java ArrayList Tutorial | EdurekaJava ArrayList Tutorial | Edureka
Java ArrayList Tutorial | Edureka
 
Generics
GenericsGenerics
Generics
 
Java Collections | Collections Framework in Java | Java Tutorial For Beginner...
Java Collections | Collections Framework in Java | Java Tutorial For Beginner...Java Collections | Collections Framework in Java | Java Tutorial For Beginner...
Java Collections | Collections Framework in Java | Java Tutorial For Beginner...
 
Collections In Java
Collections In JavaCollections In Java
Collections In Java
 
Java collection
Java collectionJava collection
Java collection
 
Java Servlets
Java ServletsJava Servlets
Java Servlets
 
Collections and generics
Collections and genericsCollections and generics
Collections and generics
 
20.3 Java encapsulation
20.3 Java encapsulation20.3 Java encapsulation
20.3 Java encapsulation
 
Java 8 Stream API. A different way to process collections.
Java 8 Stream API. A different way to process collections.Java 8 Stream API. A different way to process collections.
Java 8 Stream API. A different way to process collections.
 
Array in Java
Array in JavaArray in Java
Array in Java
 
Java exception
Java exception Java exception
Java exception
 
sets and maps
 sets and maps sets and maps
sets and maps
 
Collections in Java
Collections in JavaCollections in Java
Collections in Java
 
Java exception handling
Java exception handlingJava exception handling
Java exception handling
 

Similar to Introduction to Java Collections Framework

Collection Framework in Java | Generics | Input-Output in Java | Serializatio...
Collection Framework in Java | Generics | Input-Output in Java | Serializatio...Collection Framework in Java | Generics | Input-Output in Java | Serializatio...
Collection Framework in Java | Generics | Input-Output in Java | Serializatio...Sagar Verma
 
24 collections framework interview questions
24 collections framework interview questions24 collections framework interview questions
24 collections framework interview questionsArun Vasanth
 
Java collections
Java collectionsJava collections
Java collectionsAmar Kutwal
 
Java Hands-On Workshop
Java Hands-On WorkshopJava Hands-On Workshop
Java Hands-On WorkshopArpit Poladia
 
ArrayList in JAVA
ArrayList in JAVAArrayList in JAVA
ArrayList in JAVASAGARDAVE29
 
ArrayList in JAVA
ArrayList in JAVAArrayList in JAVA
ArrayList in JAVASAGARDAVE29
 
Collections Java e Google Collections
Collections Java e Google CollectionsCollections Java e Google Collections
Collections Java e Google CollectionsAndré Faria Gomes
 
Advanced Java - UNIT 3.pptx
Advanced Java - UNIT 3.pptxAdvanced Java - UNIT 3.pptx
Advanced Java - UNIT 3.pptxeyemitra1
 
Java 103 intro to java data structures
Java 103   intro to java data structuresJava 103   intro to java data structures
Java 103 intro to java data structuresagorolabs
 
Java collections
Java collectionsJava collections
Java collectionspadmad2291
 
Java Programming Comprehensive Guide.pptx
Java Programming Comprehensive Guide.pptxJava Programming Comprehensive Guide.pptx
Java Programming Comprehensive Guide.pptxrangariprajwal4554
 
Slide Dasar Materi Java Collection Framework
Slide Dasar Materi Java Collection FrameworkSlide Dasar Materi Java Collection Framework
Slide Dasar Materi Java Collection FrameworkBayu Rimba
 

Similar to Introduction to Java Collections Framework (20)

Collection Framework in Java | Generics | Input-Output in Java | Serializatio...
Collection Framework in Java | Generics | Input-Output in Java | Serializatio...Collection Framework in Java | Generics | Input-Output in Java | Serializatio...
Collection Framework in Java | Generics | Input-Output in Java | Serializatio...
 
24 collections framework interview questions
24 collections framework interview questions24 collections framework interview questions
24 collections framework interview questions
 
Collection framework
Collection frameworkCollection framework
Collection framework
 
Java collections
Java collectionsJava collections
Java collections
 
Java collections
Java collectionsJava collections
Java collections
 
Java util
Java utilJava util
Java util
 
Introduction to es6
Introduction to es6Introduction to es6
Introduction to es6
 
Java Hands-On Workshop
Java Hands-On WorkshopJava Hands-On Workshop
Java Hands-On Workshop
 
ArrayList in JAVA
ArrayList in JAVAArrayList in JAVA
ArrayList in JAVA
 
ArrayList in JAVA
ArrayList in JAVAArrayList in JAVA
ArrayList in JAVA
 
Java for newcomers
Java for newcomersJava for newcomers
Java for newcomers
 
Collections Java e Google Collections
Collections Java e Google CollectionsCollections Java e Google Collections
Collections Java e Google Collections
 
Collections
CollectionsCollections
Collections
 
Advanced Java - UNIT 3.pptx
Advanced Java - UNIT 3.pptxAdvanced Java - UNIT 3.pptx
Advanced Java - UNIT 3.pptx
 
Collections in Java Notes
Collections in Java NotesCollections in Java Notes
Collections in Java Notes
 
Java 103 intro to java data structures
Java 103   intro to java data structuresJava 103   intro to java data structures
Java 103 intro to java data structures
 
Lecture 9
Lecture 9Lecture 9
Lecture 9
 
Java collections
Java collectionsJava collections
Java collections
 
Java Programming Comprehensive Guide.pptx
Java Programming Comprehensive Guide.pptxJava Programming Comprehensive Guide.pptx
Java Programming Comprehensive Guide.pptx
 
Slide Dasar Materi Java Collection Framework
Slide Dasar Materi Java Collection FrameworkSlide Dasar Materi Java Collection Framework
Slide Dasar Materi Java Collection Framework
 

Recently uploaded

CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 

Recently uploaded (20)

CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 

Introduction to Java Collections Framework

  • 1. Collection Framework Ankit Kumar Garg    
  • 2. Introduction to collections  a Collection is a container of Objects, it groups  many Objects into a single one  Arrays are too static (but can be also  considered to be collections)  Arrays have very few built­in features  Originally, Java contained a few collection  classes, like Vector, Hashtable etc.    
  • 3. Java 1.2 introduced the Collections Framework  Another example of a collections framework is  the STL(Standard Template Library) in C++.    
  • 4. What is a Collections Framework  The Java Collections Framework consists of:  Interfaces  –  abstract  data  types  representing  various  collections.  Allow  collections  to  be  manipulated  independently of their implementations.  Implementations  –  these  are  the  concrete  implementations of the interfaces. They are reusable data  structures.    
  • 5. Algorithms  –  these  are  able  to  perform  useful  computations,  like  searching  and  sorting,  on  the  implementations  of  the  interfaces.  So,  the  algorithms  are  polymorphic and therefore are reusable functionality.    
  • 6. Benefits of Collections  Reduces programming effort  Increases program speed and quality  Allows interoperability among unrelated APIs   Reduces effort to design new APIs  Helps to reuse the code    
  • 7. Interfaces Here are the core Collections interfaces: Note: Collection is at the root, Map is separate All  Collections  interfaces  and  implementation  classes reside in the java.util package.    
  • 8. Collection interface  add(...) ­ adds an element  contains(...) ­ checks if the specified element  exists  remove(...) ­ removes an element  clear() ­ removes all elements  size() ­ returns the number of elements   toArray() ­ converts the Collection to an array      etc.
  • 11. Confusing words  collection (lowercase ‘c’),  which represents any of  the data structures in which objects are stored and iterated  over.  Collection  (capital  ‘C’),  which  is  actually  the  java.util.Collection  interface  from  which  Set  and  List  extend.  Collections (capital ‘C’ and ends with ‘s’),  which is actually the java.util.Collections class that holds a  pile of static utility methods for use with collections.    
  • 12. java.util.List  A List is a ordered collection of objects  Implemented by ArrayList, Vector & LinkedList  Users have control on where in List, new  element in the list should be added  List can contain duplicates element    
  • 13. ArrayList   It is an growable array. It gives you fast  iteration and fast random access.  Adding element require O(n) time.  ArrayList is not synchronized   Choose it when you need fast iteration but  aren’t as likely to be doing a lot of insertion and  deletion.    
  • 14.    
  • 15. Vector  Vector is a holdover from the earliest days of  Java  A Vector is basically the same as an ArrayList,  but Vector() methods are synchronized for  thread safety.    
  • 16. LinkedList  Doubly Linked List implementation of List  Interface  provide special method to get , remove and  insert element at the beginning and at the  end  of List  Very efficient  for sequential access  and  insertion of element in the middle of the List     
  • 17.    
  • 18. java.util.Set  A Set is a collection that does not contain any  duplicate element.  Element that are put in  a set must override  equals() method to establish uniqueness    
  • 19. HashSet  It is an unsorted, unordered Set  A Set BackedUp by HashMap  can contain null  basic operation take constant time  Iteration order may not always be same  Choose set where lookup time has to be  optimized   Operations are not synchronized  
  • 21. LinkedHashSet  It is an ordered version of HashSet  It maintains a doubly­linked List across all  elements.  can contain null  Use it instead of HashSet when you care about  the iteration order    
  • 22.    
  • 23. TreeSet  It is guaranteed to be in ascending order, sorted  by the natural order of the element or by the  comparator provided.  It uses a Red­Black tree structure  can't contain null  User defined class must implement comparable  interface   It is not synchronized  
  • 24. Map interface  Map maps keys to values  Used to lookup object based on key  Doesn't extend Collection, but provides similar  methods  – put(), get(), remove() operate with single key­value pairs  – containsKey(), containsValue() check for existense  – Collection views: keySet(), values(), entrySet()    
  • 25. java.util.HashMap  Implementation is based on Hashtable  Ideal for fast lookup  Provide constant time performance for inserting  & locating pair  Allows one null key in a collection and multiple  null values in a collection    
  • 26. java.util.Hashtable  Hashtable is the synchronized counterpart to  HashMap.  HashMap lets you have null values as well as  one null key, a Hashtable doesn’t let you have  anything that’s null.    
  • 27. java.util.LinkedHashMap  It maintains insertion order  it will be somewhat slower than HashMap for  adding and removing elements  you can expect faster iteration with a  LinkedHashMap    
  • 28. java.util.TreeMap  Implemented based on Red­Black tree  The keys appear sorted  Basic operation take log(n) time  Methods are not synchronized