As a developer everybody in their careed must have faced the requirement where you need resizable collection where you can do add, remove, retrievale(FIFO).
In every application i see using List(ArrayList) to satisy this requirement but my question why not developer go for Queue(probably ArrayDeque) . As per my current understanding i find both ArrayList(List) and ArrayDeque(Queue) equally good for the requirement i stated. But still i never spotted queue in my career , always find only List.
So my question is why not Queue is preferred over List. I am sure there must be some reason but somehow i am missing that understanding?
Update:- here is my clear requirements
1)Addition happens at end and should be fast.Probably O(1)
2)Iteration should be fast
3)lookup and removal of any specific element should be faster.
Going by above requirement i think Arralist makes sense over ArrayDeque . Here are my pointwise reason
1)Both Arraylist and ArrayDeque will be O(1) . Right?
2)Iteration performance will be same for both as it will be based on index . For ArrayDeque index will be based on timestamp whereas for arraylist user can explicitly mention index. Right?
3)It will be O(1) for both as lookup will happen based om index