List in JavaPosted by Akhila on January 17th, 2020 List Interface in Java: In the collection, there is a child interface called as Java.util.List. This is a collection of ordered objects in which copied values are saved. List stores in insertion order, it enables positional access and insertion of elements. List Interface is implemented by the following classes Stack, Vector, LinkedList, and ArrayList. To get in-depth knowledge on Java, take Java Online Training. Declaration of List: public abstract interface List extends Collection. Creation of List Objects: The list is an interface and we can create instances of List by using different classes. List d = new ArrayList(); List c = new LinkedList(); List b = new Vector(); List a = new Stack(); Operations on List: List interface extends collection, so it helps all the operations of collection interface, with the following extra operations: 1. Positional Access: List enables addition, removing, getting, and setting operations depending on the numerical positions of elements in List. The list has the below methods to perform these operations.
Get more on How to learn Java? 2. Search: List also provides methods for searching elements and returns its numeric position. The below methods are supported by the list for performing this operation.
3. Iteration: ListIterator(extends Iterator) is used for iterating over the list element. List iterator is a bidirectional iterator. 4. Range-view: A method to get the List view of the part of the given list among two indices is given by the List Interface. It supports the operations using the below methods List subList(int fromIndex, int toIndex) returns List view of given list between fromIndex (included) and toIndex (not included). I hope you got the overview of List in Java. Follow my articles, to get more updates on Java Programming language. To learn, take Java Online Course from basics. Like it? Share it!More by this author |