This is the thirteenth blog post of the back-end interview collection - java
a collection of interview skills❗❗❗
1. What are the common data structures in Java and their characteristics
-
array
-
Arrays are the most commonly used data structures.
-
An array is characterized by a fixed length, can be indexed by a subscript, and all elements are of the same type.
-
-
the list
-
A list is similar to an array, except that its size can change.
-
Lists are typically implemented as a fixed-size array that will automatically resize when needed.
-
Lists can contain repeated elements.
-
-
gather
- Sets are similar to lists, but they cannot contain duplicate elements
-
the stack
-
The stack only allows operations on the last inserted element, that is, first in, last out.
-
If you remove the top element of the stack, then you can operate on the second-to-last element, and so on.
-
The commonly used methods here are:
-
peek()
Return without removing the top element of the stack -
push()
add an element to the stack -
pop()
Return and delete the top element of the stack.
-
-
-
queue
-
A queue is somewhat similar to a stack, except that the first element inserted in the queue is also the first element to be deleted, that is, first in first out.
-
Commonly used methods are:
-
peek()
return header element
-
-