Java List Interface
The List Interface in Java extends the Collection Interface and is a part of java.util package.
It is used to store the ordered collections of elements. So in a Java List, you can organize and manage the data sequentially.
Maintained the order of elements
Allows the duplicate elements.
The implementation classes of the List interface are ArrayList, LinkedList, Stack, and Vector.
Can add Null values that depend on the implementation.
Java List – Operations
Since List is an interface, it can be used only with a class that implements this interface. Now, let’s see how to perform a few frequently used operations on the List.
- Operation 1: Adding elements to List using add() method
- Operation 2: Updating elements in List using set() method
- Operation 3: Searching for elements using indexOf(), lastIndexOf methods
- Operation 4: Removing elements using remove() method
- Operation 5: Accessing Elements in List using get() method
- Operation 6: Checking if an element is present in the List using contains() method
- import list in java from java.util.package;
- Now add data in list in this list am define a list type is String, so add data as String data .
- Now get a specific list data and print.
SOCIAL SHARE CARD GENERATOR