Deque interface in java

Deque interface: Deque interface represents a double-ended-queue. A deque represents a linear collection of elements that support insertion, retrieval and removal of elements at both ends. Deques can be used both as FIFO (first-in, first-out) and LIFO (last-in, first-out). In a deque all new elements can be inserted, retrieved and removed at both ends. Commonly … Read more

Queue interface in java

Queue interface: Queue represents a collection for holding elements prior to processing. Note: Queue declares its own methods in addition with methods declared in Collection interface. Commonly used methods of Queue Interface: 1. add(Object obj): Inserts the specified element into this queue. Returns true if queue changed after the operation otherwise returns false. Syntax: public … Read more

SortedMap interface in java

SortedMap interface: SortedMap interface extends Map interface. It maintains its entries in ascending key order. Commonly used methods of SortedMap interface: 1. comparator(): Returns comparator for this sorted map. It returns null if the natural ordering is used for this map. Syntax: public Comparator comparator(). 2. firstKey(): Returns the first key in this map. Syntax: public Object firstKey ( ). … Read more

Map.Entry interface in java

Map.Entry interface: Map.Entry interface provides the facility to work with a map entry. The entrySet( ) method of the Map interface returns the set of map entries i.e. set of Map.Entry objects. Commonly used methods of Map.Entry interface: 1. equals(Object obj): Returns true if specified object is equals to this map otherwise returns false. Syntax: … Read more

Map interface in java

Map interface: A map represents an object with key-value pair.  A map cannot contain duplicate keys and one key can map to at most one value. Commonly used methods of Map interface: 1. clear(): Removes all key-value pairs from this map. Syntax: public void clear() 2. containsKey(Object k): Returns true if this map contains specified … Read more

SortedSet interface in java

SortedSet interface: SortedSet interface extends Set interface. SortedSet interface maintain ascending order in its elements.  Note: SortedSet interface declares its own methods in addition of methods declared in Set interface.  Commonly used methods of SortedSet interface: 1. comparator(): Returns comparator for this sorted set. It returns null if the natural ordering is used for this set. Syntax: public Comparator comparator(). … Read more

Set interface in java

Set interface: A set represents a group of elements which can’t contain a duplicate element. It extends the collection interface.  Note: Set interface contains only methods inherited from Collection interface and adds the restriction that can’t contain a duplicate element.  Commonly Used methods of Set interface: 1. add(Object obj): Add object to the calling collection. … Read more

List interface in java

List interface: A List represents an ordered or sequenced group of elements. It may contain duplicate elements. It extends the collection interface.  Note: Elements can be inserted or retrieved by their position in the list. Position or index value starts from 0. List interface defines its own methods in addition to the methods of collection … Read more

Collection interface in java

Collection interface:   Collection interface is the root interface in the collection hierarchy. It declares the core methods for all collections. Commonly used methods of Collection interface: 1. add(Object obj): Add object to the calling collection. It returns true if collection changed after this call otherwise returns false. Syntax: public boolean add(Object obj) 2. addAll(Collection c): … Read more

Collection interfaces in java

Collection interfaces: Collection interfaces are abstract data types that represent collections and allow collections to be manipulated independently of the details of their representation. Collection interfaces are given below: 1. Collection interface: Collection interface is the root interface in the collection hierarchy. It declares the core methods for all collections. 2. List interface: A List represents … Read more