default size of Hashtable,Hashmap,Hashset,Vector,Arraylist

The Collection framework contains all the classes and interfaces inside java.util package. 

Hashtable :- A Hashtable class implement Map interface.it is an unordered collection of key-value pairs, with a unique key for each value.it is synchronized class. Hashtable doesn’t allow any null key or value.it is not more faster compared to HashMap.

HashMap :- A Hashmap class implement Map interface. HashMap allows one null key and multiple null values.it is not synchronized class. That’s why it is faster and take less memory.

HashSet :- A HashSet class implement Set interface.it does not allow duplicate value. HashSet is an unordered collection and does not maintain insertion order.

Vector :- A Vector class implement List interface.it is a synchronized class.Vector implements a dynamic array which means it can grow or shrink as required. 

ArrayList :- A ArrayList class implement List interface. ArrayList maintains the insertion order i.e order of the object in which they are inserted.its allow duplicate value. ArrayList class uses a dynamic array for storing the elements.

The default size of Hashtable,Hashmap,Hashset,Vector and Arraylist are:

  • Hashtable = 11
  • Hashmap = 16
  • Hashset = 16
  • Vector = 10
  • Arraylist = 10

default size of Hashtable,Hashmap,Hashset,Vector,Arraylist Read More »