While the other answers are the correct way to create an ArrayList
. You could simply cast it to a List
. This would leave the same underlying data structure (LinkedList
) but you can use it as a List then.
Queue outputQueue = new LinkedList();
List list = (List)outputQueue;
Weather or not this is a better way to do what you need depends on how you are using the List. You have to decide if the cost of create a new ArrayList
is worth the the potential speed increase in accessing your data. Take a look at When to use LinkedList<> over ArrayList<>?.