Collection is a framework for keeping a group of objects. It is not synchronized. They are basically of two types: list and set. Some of them are ordered while some allow duplicates. List can contain duplicate elements while set cannot
Features of List
- Ordered
- Eg: Arraylist, linkedlist
ArrayList
- positional access : Constant time
- Addition and deletion: Linear time
- positional access : Linear time
- Addition and deletion: Constant time
Features of Set
- Eg. HashSet, TreeSet
HashSet
- Faster but offers no ordering guarantee
- Since the iteration is linear in sum of number of entries and capacity, choosing the size of hashset makes the code faster
If we need to use the operations in SortedSet or if in-order iteration is important to you, use TreeSet.
Since their is no synchronization in Collection, it is generally faster than Hashtable and Vector.
More information is available at following link
No comments:
Post a Comment