Main BLOGGER
Google
WWW THIS BLOG
Tuesday, December 27, 2005
 
Java Tutorials
Java online Tutorial


Java Collection Tutorial

Legacy Implementation: (Synchronized)
1. Vector
2. Hashtable (does not allow null keys and values)

Collection Interfaces:
1. Collection: Set-->SortedSet, List, Queue,
2. Map-->SortedMap,

General-Purpose Implementations: (non-synchronized, dynamic sized)
- HashXXX: Hash table implementation, the best all-around implementation
- TreeXXX: red-black tree implementation, it can search, insert, and delete in O(logn) time
- LinkedXXX: doubly-linked list implementation, good for frequently insertion and deletion
- MapXXX allows null keys and values while Hashtable will not.
- Use static factory wrapper to provide synchronization.

1. Set: HashSet, LinkedHashSet; SortedSet: TreeSet
2. List: ArrayList, LinkedList
3. Queue: PriorityQueue
4. Map: HashMap, TreeMap, LinkedHashMap

Convenience for compability
1. Arrays.asList(): allows an array to be viewed as a list
2. Collection.toArray()

*WeahHashMap
An implementation of the Map interface that stores only weak references to its keys. Storing only weak references allows key-value pairs to be garbage-collected when the key is no longer referenced outside of the WeakHashMap. This class provides the easiest way to harness the power of weak references. It is useful for implementing "registry-like" data structure, where the utility of an entry vanished when its key is no longer reachable by any thread. It is can be used to implement cache data structure as well.



<< Home

Powered by Blogger

Google
WWW THIS BLOG