- List is ordered collection of objects (Integer, String etc).
- Duplicate values are allowed.
- List preserve insertion order of elements i.e it is ordered by default.
- List allows add, remove, get and set operations based on numerical positions of elements
- List is a interface which extends collections interface.
Possible ways to access list are:-
List a = new ArrayList(); List b = new LinkedList(); List c = new Vector(); List d = new Stack();
- void add(int index,Object O): adds given element at specified index.
- boolean addAll(int index, Collection c): adds all elements from specified collection to list.
- Object remove(int index): removes an element from the specified index.
- Object get(int index): returns element at the specified index.
- Object set(int index, Object new): replaces element at given index with new element.
Did you notice?
Return type of remove, get and set function is object.
Why they call it java and why java is represented by coffee beans or cup of coffee?
How to generate code coverage report in java? Jacoco | Graphical Report
what is the difference in Interface of Java7, Java8 and Java9?
How to configure Eclipse IDE for Scala?
What are the different Eclipse Versions | Comparison
Brain Teaser - Guess which exception is thrown?
Why do abstract classes in Java have constructors?
Is Java Pure Object Oriented Programming Language?