Java has introduced new collection interfaces in Jdk 1.6 which is also called as Java 6.0, they are as following:
- Deque- Deque is a double ended queue and it allows elements to be inserted or removed from either the beginning or end of the sequence. Most Deque implementations place no fixed limits on the number of elements they may contain, but this interface supports capacity-restricted deques as well as those with no fixed size limit.
Methods exist in two forms:
- One throws an exception if the operation fails
- returns a special value (either null or false, depending on the operation)
- BlockingDeque-It is similar to Deque and provides additional functionality. When we try to insert an element in a BlockingDeque, which is already full, it can wait till the space becomes available to insert an element. We can also specify the time limit for waiting.
BlockingDeque methods come in four forms:
- Throws an exception,
- Returns a special value (either null or false, depending on the operation),
- Blocks the current thread indefinitely until the operation can succeed, and
- Blocks for only a given maximum time limit before giving up.
- NavigableSet- NavigableSet methods used to return the closest matches of elements for the given elements in the collection. ConcurrentSkipListSet is one of the class that implements NavigableSet. A NavigableSet may be accessed and traversed in either ascending or descending order. This interface defines methods for finding the element in a list. For example lower() method used for finding the element which is less than the given value.
- NavigableMap-In NavigableMap methods will use key value pairs to retrieve the value. A NavigableMap may be accessed and traversed in either ascending or descending key order. ConcurrentSkipListMap is the one of the class which implements NaviagableMap.
The following are the new collection classes introduced in Java 6.0:
- ArrayDeque- ArrayDeque Class implements a Deque interface. This class has no capacity restriction.
- ConcurrentSkipListSet- ConcurrentSkipListSetand TreeSetimplement the NavigableSetinterface.
- ConcurrentSkipListMap- ConcurrentSkipListMap and TreeMap implement the NavigableMap interface.
- LinkedBlockingDeque- A LinkedBlockingDeque is a Collection class, which implements BlockingDeque interface in which we can specify maximum capacity if we want.
Modified Classes:
- LinkedList- LinkedList is modified to implement Deque.
- TreeSet- TreeSet is modified to implement NavigableSet.
- TreeMap- TreeMap is modified to implement NavigableMap.
- Collections- Two new methods newSetFromMap and AsLifoQueue are added in Collections class.
Example:
package visualbuilder; } |
Output:
Java Discussion
- - Java web application
- - Difference between BMT an
- - Replace getParameterValue
- - Interviewing Next week -
- - Sudoku solver





