Complexity of List Interface in Java
Operation |
Time Complexity |
Space Complexity |
---|---|---|
Adding Element in List Interface |
O(1) |
O(1) |
Remove Element from List Interface |
O(N) |
O(N) |
Replace Element in List Interface |
O(N) |
O(N) |
Traversing List Interface |
O(N) |
O(N) |
List Interface in Java with Examples
The List interface in Java provides a way to store the ordered collection. It is a child interface of Collection. It is an ordered collection of objects in which duplicate values can be stored. Since List preserves the insertion order, it allows positional access and insertion of elements.
Table of Content
- List Interface in Java
- Declaration of Java List Interface
- Example of Java List
- Operations in a Java List Interface
- Complexity of List Interface in Java
- Iterating over List Interface in Java
- Methods of the List Interface
- Java List vs Set