Collection Framework
In this blog I will share with you the most important concept of Java that is Collection API. We will see all the Collection Class and Interfaces in details
Collection in Java
Collection in java is a Framework that provide a architecture to store and manipulate the object.
In simple word we can say collection framework is used to store the object and also we can perform many operation like searching, insertion, Deletion and many more.
Java Collection means a single unit of object and It have interface (List, Set, Queue, Deque) and have classes(ArrayList, Vector, LinkedList. PriorityQueue, HashSet, LinkedHashSet, TreeSet)
Why we called Collection is a Framework, because it have a readymade Interface and Classes and use of collection is optional we can also create own architecture.
Provide the facility to iterate the elements in the forward direction only.
Method of Iterator interface
public boolean hasNext() - Return true if collection has next element
public object next() - Return next object
public void remove() - Remove
Collection Interface:
It is the interface and all the sub interface of the Collection Framework extend the collection interface and all the class implement the collection interface.We can say it is the foundation of the Collection Framework.
List Interface:
It is the child interface of the collection interface it behave like the list type data structure .
It store the ordered collection of object, it have duplicate values also.
It is implemented by the classes LinkedList, ArrayList,Vector.and Stack.
List<datatype> list2 = new LinkedList();
List<datatype> list3 = new Vector();
List<datatype> list1 = new ArrayList();
List<datatype> list4 = new Stack();
It store the data in node form and use the concept of doubly linked list internally to store the data. It can store duplicate element also.
The insertion and deletion operation in linkedlist is fast because there is no shifting.
import java.util.*;
public class MyList{
public static void
}

Comments
Post a Comment
DON'T COMMENT LINK.