Skip to main content

Vector

Learn Vector (List Interface, Collection Framework) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.

What is a Vector? A Vector is a resizable array, just like ArrayList , with one big difference: every method is synchronized , so only one thread at a time can use it. It is one of the oldest classes of Java (from version 1.0, before the Collection Framework existed) and was later retrofitted to implement List . Package java.util . Implements List , RandomAccess , Cloneable , Serializable . Keeps insertion order , allows duplicates and null , and reads by index in O(1). Thread-safe because each method locks the vector. This makes it slower than ArrayList when only one thread is used. Default...

More lessons in List Interface