Clean • Professional
Legacy Collections are the oldest data structure classes in Java, created before Java 1.2—before the modern Collection Framework was introduced.
Even though Java later added the Collection Framework, these classes were kept for backward compatibility, and most of them were redesigned internally to work with the new framework.
All legacy classes are available in the java.util package.
Legacy Collections refer to these old classes and interfaces:

These classes:
addElement()Vector is a dynamic array similar to ArrayList, but it is synchronized, making it thread-safe but slower.
Iterable
└── Collection
└── List
└── VectorKey Points
Example
import java.util.*;
Vector<String> vec = new Vector<>();
vec.add("Java");
vec.add("Python");
vec.add("C++");
System.out.println(vec);
Stack is a legacy LIFO (Last-In-First-Out) data structure that extends Vector.
Key Points
Example
import java.util.*;
Stack<Integer> stack = new Stack<>();
stack.push(10);
stack.push(20);
stack.push(30);
System.out.println(stack.pop()); // 30
Modern Replacement:
Use ArrayDeque instead (much faster and recommended).
Hashtable is a synchronized Map implementation that stores data in key-value pairs.
Map
└── HashtableKey Points
Example
import java.util.*;
Hashtable<Integer, String> table = new Hashtable<>();
table.put(1, "Java");
table.put(2, "Python");
System.out.println(table.get(1));
Modern Replacement:
Use HashMap or ConcurrentHashMap (better performance).
Enumeration is an old interface used to iterate over legacy classes like Vector and Hashtable.
Key Points
Example
import java.util.*;
Vector<String> vec = new Vector<>();
vec.add("Java");
vec.add("C++");
Enumeration<String> en = vec.elements();
while (en.hasMoreElements()) {
System.out.println(en.nextElement());
}
Properties is a specialized class (extends Hashtable) used to store String–String key-value pairs, mostly for configuration files.
.properties config filesimport java.util.*;
import java.io.*;
public class Main {
public static void main(String[] args) throws Exception {
Properties p = new Properties();
p.setProperty("username", "admin");
p.setProperty("password", "12345");
p.store(new FileOutputStream("config.properties"), "Config File");
}
}
Because they:
addElement(), removeElement())Use them only when:
Otherwise → avoid them.
| Legacy Class | Description | Modern Replacement |
|---|---|---|
| Vector | Synchronized dynamic array | ArrayList |
| Stack | LIFO (extends Vector) | ArrayDeque |
| Hashtable | Synchronized Map, no nulls | HashMap / ConcurrentHashMap |
| Enumeration | Legacy iterator | Iterator / ListIterator |
| Properties | Config storage (String–String) | Still used (no replacement) |