Convert a Queue to a List (LinkedList to ArrayList)

This example shows how to do a Queue to List conversion. Since both Queue and List are of type Collection we can create any of them using the constructor that takes another Collection object as argument.
Here we create a LinkedList and add items to it, then we create an ArrayList and pass the LinkedList as an argument. Finally we print out the contents of the newly created ArrayList.

I bet you have already guessed what the output from the code will be, but here it comes:

Search for more Java info on this site here:
Custom Search

Please type any questions here.