Stacks are like a stack of plates or trays in which the topmost one gets picked first.Linked list emulates your browsing history, trains coaches who are connected to each other, etc.Let us try to understand the real-life use cases: Now that we know what Collection in Java is,
They are used to standardize the way in which objects are handled in the class. Technically, a collection is an object or a container that stores a group of other objects.Ī Collection in Java is an object which represents a group of objects, known as its elements. This piggy bank is called a Collection and the coins are nothing but objects. We all had it during our childhood where we used to store our coins. What is a Collection in Java?Ĭonsider the example of a piggy bank.
Java Collection framework provides many interfaces ( List, Queue, Deque, Set) and classes ( ArrayList, Vector, LinkedList, PriorityQueue, HashSet, LinkedHashSet, TreeSet). It is a hierarchy of interfaces and classes that provides easy management of a group of objects. Collections in Java is a framework that stores and manipulates a group of objects.