Skip to content
019_Java中ArrayList和LinkedList的区别 episode artwork

Aug 11, 2022 3 min

019_Java中ArrayList和LinkedList的区别

from 2020年JAVA面试208题

ArrayList和LinkedList的区别 LinkedList和ArrayList的区别主要来自于他们俩的数据结构不同 ArrayList是基于数组实现的,LinkedList是基于双链表实现的 ArrayList是基于数组的数据结构,数组在内存中存储数据的空间是连续的,可以通过下角标直接访问数组中的元素,因此在随机访问集合元素时有较好的性能。 ArrayList获取数据的时间复杂度是O(1),但是要插入、删除数据的开销很大,因为要将插入位置之后的所有元素进行后移操作。例如买票时,有人插队,则插队的位置后面的所有人都要后移,消耗就比较大。 相比于ArrayList,LinkedList的随机访问元素时性能较差,因为双向链表在内存中存储数据不是连续的;但在插入,删除操作是很快的,那么这个链表呢,就好比幼儿园小朋友手拉手围成一个大圈儿做游戏,这时候来了一个新的小朋友要加入,只需要任意2个小朋友松开手,这个新的小朋友加入即可,其他小朋友不用动。所以性能相对ArrayList要好很多 因为LinkedList它是链表操作,所以在插入或删除的时间复杂度仅为O(1) 。 使用场景 如果应用程序对数据有较多的随机访问,首选肯定是ArrayList集合; 如果应用程序有更多的插入或者删除操作,较少的数据读取,LinkedList对象要优于ArrayList对象; 不过ArrayList的插入,删除操作也不一定比LinkedList慢,如果在集合靠近末尾的地方插入,那么ArrayList只需要移动较少的数据,而LinkedList则需要一直查找到列表尾部,反而耗费较多时间,这时ArrayList就比LinkedList效率要高。

Episode details come from the podcast's RSS feed.

Embed this episode

Ready to play

019_Java中ArrayList和LinkedList的区别

0:00 3:42

No transcript yet.

Requests help us decide what to transcribe next.

F*ck Surviving, We're Thriving Malina Lopez Hello beautiful humans! I have been on my holistic healing journey since 2020 after a massive awakening thanks to a sound healing ceremony. Since then I have dedicated my free time to health and healing (when I'm not too consumed with being a mama of two). Health is something that has always been important to me, but healing myself in a holistic way has allowed me to become a version of myself I am truly proud of. I had no idea there was an option for living life outside of survival mode. As someone who has been in some state of fight, flight or freeze since I was a small child the idea of any other life seemed out of reach and down right unrealistic. I honestly thought how I was living and feeling was totally normal. Once I started to heal all parts of myself down to the cells I am made up of I realized life is so much more than people pleasing, anxiety attacks and living life in a haze. I've been exciting that survival mode and entering my era of thriving. I feel ready and so e Explicit Demonic Sweaters Podcast Demonic Sweaters My name is Justin AKA Demonic Sweaters. In 2015 I started a podcast to talk about the stuff I find interesting and to interview interesting people. I took a long break during the 2020 pandemic, but started up again in early 2024. I've had great luck in getting amazing guests lined up since I've returned! Topics talked about are: Music, art, drums, paranormal, conspiracies, UFOs, self-employment, life struggles, money, health, philosophy, or basically anywhere our conversations wonder. Explicit

Frequently asked questions

How long is this episode of 2020年JAVA面试208题?

This episode is 3 minutes long.

When was this 2020年JAVA面试208题 episode published?

This episode was published on August 11, 2022.

Can I download this 2020年JAVA面试208题 episode?

Yes. Use the download control on the episode player to save the publisher-provided media file.