Iterate or loop LinkedList collection of String objects in java (with example)

Linked list in java is a doubly-linked list. Insertion order is maintained in a linked list. LinkedList extends AbstractSequentialList class & implements List, Deque,  Cloneable, Serializable interfaces. LinkedList class is not thread safe. In multi threaded environment, it should be synchronized externally. The iterators returned by LinkedList class’s iterator and listIterator methods are fail-fast. LinkedList class… Read More »

Retain & remove elements/ nodes of linkedlist collection (Java/ example)

Given a LinkedList collection in java, we would like retain certain elements or nodes of linkedlist. We would like to remove rest of elements from linkedlist. The LinkedList class extends AbstractSequentialList and implements the List interface. LinkedList class have following method to retain elements/ nodes. boolean retainAll(Collection<?> c) Retains only the elements in this list… Read More »

Remove or delete nodes/String objects from LinkedList collection (java/ example)

Linked list in java is a doubly-linked list. Insertion order is maintained in a linked list. LinkedList extends AbstractSequentialList class & implements List, Deque,  Cloneable, Serializable interfaces. LinkedList class is not thread safe. In multi threaded environment, it should be synchronized externally. The iterators returned by LinkedList class’s iterator and listIterator methods are fail-fast. 1. Methods… Read More »

Add or insert elements/ nodes to linkedlist in java (with example)

Linked list in java is a doubly-linked list. Insertion order is maintained in a linked list. LinkedList extends AbstractSequentialList class & implements List, Deque,  Cloneable, Serializable interfaces. LinkedList class is not thread safe. In multi threaded environment, it should be synchronized externally. The iterators returned by LinkedList class’s iterator and listIterator methods are fail-fast. LinkedList class… Read More »

Iterate or loop arraylist collection of String objects/elements in java (example)

ArrayList class is resizable array implementation of the List interface. ArrayList maintains the insertion order of element or string objects. ArrayList allows the duplicate elements & we can randomly access elements by index. ArrayList is not thread safe. If multiple threads access an ArrayList instance concurrently, then arraylist must be synchronized externally. The iterators returned… Read More »

Page 20 of 42« First...10...1819202122...3040...Last »