Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Difference between ArrayList and LinkedList?  RSS feed

 
samir vasani
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

Please tell me the difference between ArrayList and LinkedList in terms of the removal of an element from both of the collections
 
D. Ogranos
Ranch Hand
Posts: 214
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
LinkedList is implemented as a double linked list. ArrayList is implemented based on an array.

Now imagine you have a loooong list, and want to remove the first element in the list. What does each version have to do internally to maintain the lists integrity (hint: the indices of each element have to be correct after removing the first element!). That should give you an idea when to use each variant.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!