What are the similarities between arrayList and linkedList?
Similarities between ArrayList and LinkedList
1. Insertion Order: The List<E> interface’s add(E e) method defines a contract that specified elements must be appended to the list. As ArrayList and LinkedList are concrete implementations of List interface they follow the contract and hence insertion order of an element is preserved.
2. clone() operations of ArrayList<E> as well as LinkedList<E> returns the shallow copy of elements. This means elements are not itself copied or backup.
3. Synchronization: ArrayList<E> and LinkedList<E> both of them are non-synchronized collection. They can be synchronized by using Collections.synchronizedList() method of Collections class. All methods are synchronized except iterator(), listIterator() and listIterator(int index).
4. Iterator: The iterators used in ArrayList<E> and LinkedList<E> are fail fast. Fail fast iterators throws ConcurrentModificationException.
5. Implementation: Both ArrayList<E> and LinkedList<E> are implementations of List<E> interface. ArrayList class provides Random Access to elements where LinkedList provides sequential access.
Tags:
Similarity between ArrayList and LinkedList
Similarities between LinkedList and ArrayList
Image Credits: Freepik