Collection Types
This lesson talks about the different types of collections available in the Collections Framework.
Question # 1
What are legacy collections?
Collections which were provided with JDK 1.0 have come to be known as legacy collections.
Examples include Hashtable
and Vector
. These are thread-safe and utilize synchronization to be so. Synchronization is expensive and can slow down the overall execution of a program.
Question # 2
What is the Collections Framework introduced in JDK 1.2?
The Collections Framework was introduced with JDK 1.2 and provided several utility collections.
The Collections Framework in JDK 1.2 avoided thread-safe collections as not all use cases require thread-safety. Synchronization code required to make collections thread-safe can also slow down performance and is unneeded in single threaded scenarios. The collections included in this framework are the ones you are most likely familiar with such as HashMap
, LinkedList
, ArrayList
etc.
Question # 3
What are wrapped collections?
When the Collections Framework was introduced in JDK 1.2, it didn't come with collections that were synchronized. However, to cater for multithreaded scenarios, the framework provided static methods to wrap vanilla collections in thread-safe wrapper ...
Level up your interview prep. Join Educative to access 70+ hands-on prep courses.