Convert a LinkedList to ArrayList

 
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

public class Main {
  public static void main(String[] args) {
    LinkedList<String> myQueue = new LinkedList<String>();
    myQueue.add("A");
    myQueue.add("B");
    myQueue.add("C");
    myQueue.add("D");

    List<String> myList = new ArrayList<String>(myQueue);

    for (Object theFruit : myList)
      System.out.println(theFruit);
  }
}
  

Output:


A
B
C
D
Home 
  Java Book 
    Runnable examples  

Collection LinkedList:
  1. Add value to the first position in a linked list
  2. Convert a LinkedList to ArrayList
  3. Remove first and last elements of LinkedList Java example