Is it the number of HashMap<Object>Objects? Don’t collections have sizes? The capacity is the largest size. Size refers to the number of elements in the collection, which is the number of Objects here. Thinking about it, it shouldn't be bytes or something. Collections store various objects. How can these objects be the same size? Some objects are more than 16 bytes.
The bottom layer of HashMap in Java8 is such an array (Node<K,V>[] table), and the initial capacity (DEFAULT_INITIAL_CAPACITY) is the default length of the tabletable when creating a new HashMap
is the initial length of the array implemented by the underlying hashmap, not the number of elements.
Is it the number of HashMap<Object>Objects? Don’t collections have sizes? The capacity is the largest size. Size refers to the number of elements in the collection, which is the number of Objects here. Thinking about it, it shouldn't be bytes or something. Collections store various objects. How can these objects be the same size? Some objects are more than 16 bytes.
The number of entries that can be stored in the Map, because the bottom layer is implemented using an array, so it is the length of the array
The bottom layer of HashMap in Java8 is such an array (Node<K,V>[] table), and the initial capacity (DEFAULT_INITIAL_CAPACITY) is the default length of the tabletable when creating a new HashMap
The number of elements that can be stored in it
The initial capacity of the container will dynamically change with the number of elements in the container.
Reflective question:
int array[] = new int[10];
Is 10 here a byte...