Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial

Lucas Santos
19,315 PointsArrayList, ArrayDeque, LinkedList Which to use??
I just finished the Data Structure Course and I learned about all these different "array like" Interfaces and Implementations like ArrayList, ArrayDeque, LinkedList etc.
I have a good understanding on all of them and as far as what their methods are I looked them up on oracle. But the question is how do I know which one to use??
Not to mentions that these Implementation classes such as ArrayList and ArrayDeque can use different Interfaces changing it's methods and what not.
In the final section of the Data Structure Course we made a Karaoke Application and we utilized ArrayDeque for that but I don't see why we couldn't have used ArrayList or on the interfaces side List instead of Queue.
We used the poll method to take the first elements of the Queue when we could have done the same thing with:
List<String> mylist = new ArrayList<>(); //pretend we have stuff in here already
String firstElement = mylist.get(0); //got the first element
mylist.remove(0); //removing the element as poll() method does
I understand Craig wanted to show ArrayDeque but im just curious because it didn't seem like we really needed it and could have achieved the same thing with ArrayList.
So i'm not sure how to choose the correct Interface or implementations when a lot of them can do the same thing but in a different manner.
1 Answer

Joseph Kawa
1,807 PointsHi Lucas,
The main difference between these three is performance. In the hypothetical application of a karaoke machine, with a large list of elements, you would prefer the performance of ArrayDeque over the other Collections types. See this explanation from stackoverflow for more details... http://stackoverflow.com/questions/6129805/what-is-the-fastest-java-collection-with-the-basic-functionality-of-a-queue