Thursday, August 6, 2020

Java Array Vs ArrayList Vs LinkedList

ArrayList is ordered collection, out of the box not synchronized. You can synchronize externally.

ArrayList is slower than Array. Use Array when you know the size of element.

ArrayList uses Array internally. When you perform add on ArrayList it creates a new Array with n+1 dimension and older element will be copied to first n elements and last n+1 will be filled with new value provided in add function.

LinkedList  is more convenient to use and let you add, remove  element from both side of collection.LinkedList do not use Array. LinkedList is a sequence of nodes. Node contains header & pointer. Header contains object and pointer contains address of next node.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home