Linked List:
- Elements are doubly linked to one another.
- Performance is slower than the Array list.
- Good choice for insertion and deletion.
- In Java 5.0 it supports common queue methods peek( ), Pool ( ), Offer ( ) etc.
Example:
public class Fruit {
public static void main (String [ ] args){
Linkedlist <String> names = new linkedlist <String> ( ) ;
names.add(“banana”);
names.add(“cherry”);
names.add(“apple”);
names.add(“kiwi”);
names.add(“banana”);
System.out.println (names);
}
}
Output:
[ banana,cherry,apple,kiwi,banana]
Maintains the insertion order and accepts the duplicates.