search

Home  >  Q&A  >  body text

JAVA集合框架

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

天蓬老师天蓬老师2766 days ago866

reply all(7)I'll reply

  • PHPz

    PHPz2017-04-18 09:46:05

    is the initial length of the array implemented by the underlying hashmap, not the number of elements.

    reply
    0
  • 黄舟

    黄舟2017-04-18 09:46:05

    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.

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-04-18 09:46:05

    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

    reply
    0
  • 高洛峰

    高洛峰2017-04-18 09:46:05

    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

    reply
    0
  • 阿神

    阿神2017-04-18 09:46:05

    The number of elements that can be stored in it

    reply
    0
  • 大家讲道理

    大家讲道理2017-04-18 09:46:05

    The initial capacity of the container will dynamically change with the number of elements in the container.

    reply
    0
  • 高洛峰

    高洛峰2017-04-18 09:46:05

    Reflective question:
    int array[] = new int[10];
    Is 10 here a byte...

    reply
    0
  • Cancelreply