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

Collection tutorial java

A collection is simply an object that represents a group of objects into a single unit. Collection framework: A collection framework is a unified architecture or a set of classes and interfaces for representing and manipulating collections. i.e. collection framework is used to store, retrieve and manipulate collections. Collection framework contains the following: Interfaces are abstract … Read more