The essential
"Because the expansion operation involves memory application and data movement, it is time-consuming. Therefore, if the size of the data to be stored can be determined in advance, it is best to ArrayList
specify the data size in advance when creating."
As shown in the following code:
ArrayList<User> users = new ArrayList(10000);
for (int i = 0; i < 10000; ++i) {
users.add(xxx);
}
Then it means that if the amount of data is greater than 10, it is best to set the required amount of data in advance.