What is the main difference between an ArrayList and a Vector?

What is the main difference between an ArrayList and a Vector? What is the main difference between Hashmap and Hashtable?

Differences between ArrayList and Vector:

- Vector is synchronized where as ArrayList is not.

- Vector has a default size of size 10, where as ArrayList has no default size.

- The Vector has a facility to specify the incremental size, where as ArrayList does not

- To view ArrayList, it needs Iterator or Enumeration, while using Vector; it needs Iterator or Enumeration to view its contents.

- ArrayList is not thread-safe whereas Vector is thread-safe.

- A Vector defaults to doubling the size of its array, while the ArrayList increases its array size by 50 percent.

Differences between Hashmap and Hashtable:

- Hashtable is synchronized where as Hashmap is not.

- Hashtable does not allow null values, where as Hashmap does.

- Hashmap does not guarantee the order of map remain constant over time.

- Hashmap implements Map interface. Hashtable implements Dictionary class which is a legacy class.

- Access to the Hashtable is synchronized on the table while access to the HashMap is not.

- Iterator in the HashMap is fail-safe while the enumerator for the Hashtable is not.
Java Collection framework and benefits
A collection is a set of heterogeneous objects. A framework makes the applications efficient, less hard coded.....
Difference between shallow cloning and deep cloning of objects in Java
Shallow cloning just allows cloning the object but not their internal parts.....
What is the difference between final, finally and finalize() in Java?
Final, finally and finalize() in Java - final – a key word / access modifier to define constants......
Post your comment