Pages

Monday, November 21, 2016

Introduction to Java Collection framework

Hi All, Let’s have a simple idea about java collection framework. Here I’d like to have small introduction about different types of collections and Implementation of List interface in collection.
Let’s discuss why we need java collection framework, Java Collection framework offer ordering, uniqueness, Association between unique keys and value, and much more

Different types of collections and characteristics

·         List (order, indexing )
·         Set(distinct elements )
o   SortedSet (Sorted Set )
    ·         Queue(Order in adding removing FIFO)
o   Deque(FIFO,LIFO behavior – Stack )
    ·         Map (Keys & Value )
o   SortedMap(Key value pairs in certain order )

Implementation of interfaces in collections

Interface and Implementations of different collection types, for an example we can implement both linkedList and ArrayList using List interface in collections. Key point to highlight here is, Interface defines behavior and Implementation defines performance

List Implementation




Array List (Dynamic Array)

       ·         When the characteristic are not sure we normally use arraylist
       ·         Fast in accessing and sorting


Linked List (Doubly linked List)

      ·         Less performance compare to ArrayList in accessing and sorting
      ·         Fast in data manipulation
      ·         Good When need to adding elements to the start(Head) – If we do same thing  in the array list it’s       very expensive as we need to shift all elements to the back
      ·         Good When there are lots of adding or removing operations need to be done

Performance Comparison Chart



Here I wish to share some code implementations that visualized primary utilization of Linked List and Array List










No comments:

Post a Comment