![]() LinkedList class can act as a list and queue both because it implements List and Deque interfaces. Memory overhead is a concern in LinkedList as LinkedList needs to store and maintain the location of next and previous node elements whereas in ArrayList at each index it holds just the actual element or object.īy default, ArrayList creates an empty list with initial capacity of 10 (when capacity not specified) while LinkedList creates an empty list with no initial capacity.ĪrrayList class can act as a list only because it i mplements List only. With over 260,000 students 50+ Java Collection and Generic Interview Questions Without wasting any more of your time, here is my list of 50+ Java interview questions on Collection and. LinkedList can be traversed in reverse direction by using descending Iterator while there is no API available for ArrayList to traverse in backward direction. Insertion of elements and removal operations are generally faster in LinkedList rather than ArrayList. Array List get (int index) operation performs in constant time o (1) while LinkedList get (int index) operation run time is o (n). ![]() In case of LinkedList it traverses through every node from start to end or end to start (closest takes priority) to retrieve the node at the specified index. Retrieval (get (int index)) and search operations are faster in ArrayList compared to LinkedList in terms of performance as ArrayList internally uses array data structure and leverages index based retrieval. 34 Java Collections Interview Questions 1) What is the Collection framework in Java 2) What are the main differences between array and collection 3). LinkedList is the doubly linked list implementation of List interface whereas ArrayList is the resizable array implementation of List interface. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |