F
F
foonfyrick2021-02-04 08:28:50
Java
foonfyrick, 2021-02-04 08:28:50

LinkedList vs ArrayList single insert and insert in a loop in the middle?

I read that a one-time insertion into the middle is the same in both cases, but if you insert many elements into the middle in a loop, then the arraylist is slower than linkedList, but when checking through measureTimeMillis {}, the time is approximately the same shows which method you need to insert the elements to see the difference ?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vasily Bannikov, 2021-02-04
@foonfyrick

Throw a million elements into the list in advance, and then insert the elements at the beginning - the effect will be immediately visible

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question