1.

Is there any other interface, which has some specific use case?

Answer»
  • Dequeue:
    • The Deque INTERFACE provides the facility of using double ended queue means we can use either end to PUSH and pop the elements.
    • ArrayDeque is one of the implementations.
    • Unlike Queue, we can add or remove elements from both sides.
    • Null elements are not allowed in the ArrayDeque.
    • ArrayDeque is faster than LinkedList and Stack.
    • CodeSnippet: Deque<String> deque=new ArrayDeque<String>();  
  • SortedSet
    • This interface extends Set and provides a total ORDERING of its elements.
    • The implementation class of the SortedSet interface has an implementation of the Comparable interface so that all the elements in the set can mutually comparable.
    • SortedSet by default do the sorting on ascending order.
    • TreeSet is an implementation of a sorted set interface.
    • Code Snippet: SortedSetsortedSet = new SortedSet();
  • NavigableSet:
    • NavigableSet is responsible for a navigable set in Java Collection Framework.
    • The NavigableSet interface inherits from the SortedSet interface.
    • It behaves like a SortedSet with the exception that we have navigation methods available in addition to the sorting mechanisms of the SortedSet.
    • For example, NavigableSet interface can NAVIGATE the set in reverse order compared to the order defined in SortedSet.
    • The classes that implement this interface are, TreeSet and ConcurrentSkipListSet
    • Code snippet: NavigableSet set = new


Discussion

No Comment Found