Comparing three implementations of List interface
Classes implementing List | Underlying data structure | Pros | Cons |
ArrayList | array | 1. Faster to access by index
2. Faster than Vector as methods are not synchronized | 1. Insertion or deletion in the middle is slower. 2. Not thread –safe. 3. Searching is sequential and hence not very efficient. |
Vector | array | 1. Faster to access by index.
2. Thread-safe access | 1. Insertion or deletion in the middle is slower. 2. Slower than ArrayList as methods are synchronized. 3. Searching is sequential and hence not very efficient. |
LinkedList | doubly linked list | 1. Allows faster inserts/delete at any location* 2. Faster than Vector as methods are not synchronized. | 1. Accessing element by index is slower. 2. Searching is sequential and hence not very efficient. |
No comments:
Post a Comment