且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Java:集合和'数据结构'之间的差异

更新时间:2023-01-14 13:11:29

数据结构是数据在内存中的存储内部表示的方式。集合是如何访问它。我强调可以这个词。

A data structure is how the data is represented inside the storage in memory. A collection is how it can be accessed. I stress on the word "can".

如果您将数据存储在LinkedList中并排序,性能将下降。相同的算法如果使用ArrayList的性能会提高。

If you store data in a LinkedList and sort it, the performance will drop. The same algorithm if you use a ArrayList the performance will enhance. Just by changing the way its represented in memory will help various factors.

你可以使用集合表示来访问它,你也可以使用index访问数据。你也可以去getFirst,getNext,getPrev。

You "can" access it using a collection representation, you "can" also use the "index" to access the data. You "can" also go getFirst, getNext, getPrev.

你的困惑在于内部存储和访问存储之间。分开2。

Your confusion is between internal storage and accessing the storage. Separate the 2.