ArrayList summary of knowledge and questions!

Have you ever used ArrayList? Just a quick introduction?

ArrayList is a common data structure in Java collection framework. It implements List interface, and also implements RandomAccess, Cloneable, Serializable interface.

Do you know what the underlying ArrayList uses to load data?

The underlying array is used to load data.

Do you know how big the initial capacity of an ArrayList was?

It starts out with zero capacity, nothing, and it just assigns an empty array.

What is the size of an ArrayList when it adds data?

An array of length 10 is initialized when added

Can ArrayList have transgressive errors?

There are out-of-bounds errors when accessing values beyond the length of the container.

Is it clear how ArrayList expanded?

Copies the data into the new array

So how much longer is the new array than the old array?

Increase the size by 1.5 times

Is ArrayList thread safe? If not, how to solve it

Not thread-safe, you can use locks to solve thread-safe problems

Locking is inefficient. Is there any other way?

You can use CopyOnWriteArrayList (more on this data structure later)

These are all common ArrayList interview questions, and we will compare them with LinkedList.