Limitations of Arrays:

  • Arrays are fixed in size. need to estimate the size of an array while declaration itself. once array created we can not increase the size of an array.
  • Arrays can hold only homogeneous data elements. Means we can add same type of elements in an array. While declaring an array we need to mention the data type.
  • int a[]= new int[10];
  • By using Object array we can add heterogeneous elements to the array.
  • Object o= new Object[10];
  • There is no underlying data structure for arrays.
  • Arrays are not recommended to use with respect to memory.
  • Performance wise arrays are good to use.

Collections 

  • Java Collection framework added in J2SE 1.2 release.
  • Collections are set of classes and interfaces.
  • By using Collections we can store and manipulate objects easily.
  • Collections can hold heterogeneous data elements.
  • Collections are no fixed in size and dynamically increase in size.
  • Collection of objects. No primitives.
  • All collection classes having underlying data structure.
  • Collections are good with respect to memory. Bad with respect to performance.

Collection interface Hierarchy:

  •  java.util package contains all collections classes and interfaces.
  • Lets see collection interface hierarchy.
  • under Collection. Set , List , Queue are the sub interfaces.

Collection interface Hierarchy

Collections Abstract classes and classes:

  • Let us see  all the abstract classes implementing all the above interfaces and classes which extending these abstract classes.
  • To Collect Objects in array format we choose Collection hierarchy classes.
  • Main abstract class is AbstractCollection.
  • AbstractSet
  • AbstractList
  • AbstractQueue
  • AbstractSequentialList
  • All the classes in Collection hierarchy are
  • TreeSet
  • HashSet
  • LinkedHashSet
  • LinkedList
  • ArrayList
  • Vector
  • Stack
  • PriorityQueue 
  • To collect unique elements we must choose Set implemented classes
  • To collect unique and duplicate elements in indexed order we choose List implemented classes.
  • To retrieve elements in FIFO manner we choose Queue implemented classes.

Collection interview Questions

Map Hierarchy:

  • In this hierarchy Hashtable and properties classes are avilable since java 1.0.
  • LinkedHashMap class is available since java 1.4
  • NavigableMap is available since java 6 and all other classes available since java 1.2.
  • SortedMap and NavigableMap are two main interfaces.
  • TreeMap
  • HashMap
  • LinkedHashMap
  • Hashtable
  • Properties are the classes. 
  • To collect objects in key, value pair format we choose Map hierarchy classes.


Collection Map Hierarchy tutorial


Instance Of Java

We will help you in learning.Please leave your comments and suggestions in comment section. if you any doubts please use search box provided right side. Search there for answers thank you.
«
Next
Newer Post
»
Previous
Older Post

No comments

Leave a Reply

Select Menu