#arraylist vs linkedlist

7 messages · Page 1 of 1 (latest)

velvet lichen
#

what is better between the 2? im a beginner and i dont want to use normal array that much because it doesnt have the feature i want. now, i just want to pick between the 2 or is there much better when creating an array or list? thanks for suggestions.

neon ermineBOT
#

This post has been reserved for your question.

Hey @velvet lichen! Please use /close or the Close Post button above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

elder charm
#

there's no "better" one, just the one that fits the current task

untold stirrup
#

ArrayList is better for storing and accessing data while, LinkedList is better for manipulating data. They both have advantages and disadvantages on what you need to do

#

ArrayList is better at retrieving certain elements from indices while LinkedList is better at inserting/removing (especially at the head or tail of the list) elements/indices and shifting it afterwards.

gritty rose
#

An array is almost always faster so if you can use it.
Awe already gave you a good answer. On top of that a native array will most likely be (partially) cached in your cpu cache. Thus array[0] array[1] will be faster. As it most likely can access the cpu cache for the next index .