Data Structure: Overview of List, Set and Map Interface


This post is to record my learning on Data structures in Java. I still remember when I first learned this concept, I felt there were so many things to memorize, so I tried to learn it through understanding. Here is a summary of what I learned about the List, Set, and Map interfaces.

List, Set, and Map

Briefly summarize the differences. List and Set are sub-interfaces under the Collection interface. The difference between Collection and Java Array is that:

  • Collection: the size is not fixed, but it can only store objects.
  • Array: the size is fixed, and it can store different data types or objects.

Map has its own interface, which is a key-value pair.

List:

  • Values can be duplicated.
  • Arranged in order.
  • Multiple null elements can be inserted.

Set:

  • Values do not appear repeatedly.
  • Unordered arrangement (ordered by HashCode).
  • Only one null is allowed to be stored.

Map:

  • Uses key-value pairs to find the value.
  • Enables quick addition, deletion, checking, and modification.
  • Values can be duplicated, but the key is unique.

Here is a general review of Collection and Map, as well as a simple classification based on usage conditions. Each interface has its own implementation or child interface, and some of them need to be understood from the source code, like random access of ArrayList, and sequential access of LinkedList, which will be easier to remember. I will share more later.