Skip to main content
How to Replace Hashtable and Vector With Hashmap, ArrayList, or LinkedList If Possible in java
Replace Hashtable and Vector With Hashmap, ArrayList, or LinkedList If Possible
The Hashtable
and Vector
classes in Java are very powerful, because they provide rich functions. Unfortunately, they can also be easily misused. Since these classes are heavily synchronized even for read operations, they can present some challenging problems in performance tuning. Hence, the recommendations are:
- Use an Array Instead of an ArrayList If the Size Can Be Fixed
- Use an ArrayList or LinkedList To Hold a List of Objects In a Particular Sequence
- Use HashMap or TreeMap To Hold Associated Pairs of Objects
- Replace Hashtable, Vector, and Stack
- Avoid Using String As the Hash Key (If Using JDK Prior to 1.2.2)
Comments
Post a Comment