+ 1
what is the difference between ArrayList and LinkedList
ArrayList also have add() and remove() methods to insert/delete the elements.Then , how LinkedList is better than ArrayList for add/remove the elements
6 Answers
+ 4
KrOW yes. Thats ok. I thought you not observed it. And i asked reply so that i want delete my reply.
But i think, link is not fully clarifying for the question about add/remove as it is most interview question. The term "resizable array" clarifies it.
mon
In addition, I want add that "arrayList in java internally uses array in implementation so when size exceeds default size then it creates a new double size array and copies old array to new array then append new elements so this resize for add will make it slow for large insert/delete operations compare to LinkedList.
(Delete also requires copying..).
Hope it helps..
+ 2
KrOW link is about arrays..
Question is about array list. Pls edit and reply..
+ 2
mon Jayakrishna🇮🇳 The link show some essentials differences between array and linked list as data structure (not java related).. Now, because ArrayList is implementen as an resizable array, its clear that the explaination will help you to understand why add and remove is most efficient in linked list
+ 1
Jayakrishna🇮🇳 you are correct.I asked about ArrayList not array..plz clarify my doubt.
+ 1
Jayakrishna🇮🇳 Yes, i took for granted that he knows tht arraylist use array as back storage 😅