List set and its traversal in Java
1. First, list < E > inherits from collection < E >, which is an interface.
① Collection (the collection framework appears in jdk1.2)
② List: is ordered, and the elements can be repeated, so that the collection system has an index.
The ArrayList and LinkedList classes that implement this interface are often used
③ ArrayList: the underlying data structure uses an array structure,
Features: the query speed is fast, but the addition and deletion is slightly slow. Thread out of sync
LinkedList: the underlying uses a linked list data structure.
Features: fast addition and deletion, slightly slower query.
Vector: (appeared in jdk1.0) the bottom layer is array data structure and thread synchronization. It is replaced by ArrayList. (it is no longer used)
2. Two traversal methods of list:
design sketch:
3. Use linklist to simulate a stack or queue data structure. Namely: stack: first in and last out; Queue: first in first out
design sketch:
The above is FIFO. If you want to change to FIFO, you can change it according to the code
The above is the whole content of this article. I hope you can like it.