A brief analysis of the differences between ArrayList and Vector in Java and between HashMap and Hashtable

  • 2020-04-01 02:13:15
  • OfStack

ArrayList and Vector are mainly from two aspects.
I. synchronicity :Vector is thread-safe, that is, it is synchronized, while ArrayList is not secure, it is not synchronized

2. Data growth: when it is necessary to grow, the default growth of Vector is 1 pei, while the ArrayList is half of the original

There are three main aspects of HashMap and HashTable.
I. historical reasons :Hashtable is based on the stale Dictionary class, and HashMap is an implementation of the Map interface introduced in Java 1.2

Synchronization :Hashtable is thread-safe, that is, synchronized, while HashMap is thread-unsafe, not synchronized

Values: only a HashMap allows you to use null values as key or value& pie for a table entry;

The Collection
├ List
│ ├ LinkedList
│ ├ ArrayList
│ └ Vector
│ └ Stack
└ Set
The Map
├ Hashtable
├ HashMap
└ WeakHashMap

Collection is the most basic Collection interface. A Collection represents a group of objects, namely Elements of the Collection.
Map provides a Map from key to value


Related articles: