JAVA集合框架
天蓬老师
天蓬老师 2017-04-18 09:44:05
0
7
861

请问各位大神,HashMap的初始化容量为16,这个16的单位是啥,是字节还是什么

天蓬老师
天蓬老师

欢迎选择我的课程,让我们一起见证您的进步~~

reply all(7)
PHPzhong

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...

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!