Java Collection Framework
Introduction
The Collection interface is the root interface in the Java collection hierarchy. A collection represents a group of objects, called elements. This interface is used to pass collections around and manipulate them where general processing is required. The main collection interfaces in the Java collection framework are as follows.
- Collection
- Set
- List
- Queue
- Map
All the interfaces are in java.util package. We can import them into your program as:
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.Set;
Set
A Set is a collection that contains no duplicate elements. We can use the Set collection when the objects in the collection do not contain duplicates for example playing cards.
public interface Set<E> extends Collection<E>
List
A List is an ordered collection also known as a sequence. Unlike Set, the list can contain duplicate elements in the collection.
public interface List<E> extends Collection<E>
Queue
A Queue collection is designed for holding elements prior to processing with some operations.
public interface Queue<E> extends Collection<E>
Map
A Map is used to map keys to values. A map cannot contain duplicate keys; and each key can map to at most one value.
public interface Map<K, V>
—
Java Tutorials
Java Tutorial on this website:
https://www.testingdocs.com/java-tutorial/
For more information on Java, visit the official website :