第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

HashMap的無參構(gòu)造函數(shù)是如何構(gòu)造初始容量為16的容器的?

HashMap的無參構(gòu)造函數(shù)是如何構(gòu)造初始容量為16的容器的?

UYOU 2019-01-17 18:58:46
HashMap無參構(gòu)造函數(shù)如下: /** * Constructs an empty <tt>HashMap</tt> with the default initial capacity * (16) and the default load factor (0.75). */ public HashMap() { this.loadFactor = DEFAULT_LOAD_FACTOR; // all other fields defaulted } 它是如何像它Javadoc中說的一樣構(gòu)造了一個初始容量為16的容器的?Node數(shù)組都不用初始化的么?至少加上一句 table = new Node<>[DEFAULT_INITIAL_CAPACITY]; 才合乎常理吧!請各位賜教!
查看完整描述

1 回答

?
墨色風雨

TA貢獻1853條經(jīng)驗 獲得超6個贊

注釋說了在第一次使用的時候才會初始化

  /**
     * The table, initialized on first use, and resized as
     * necessary. When allocated, length is always a power of two.
     * (We also tolerate length zero in some operations to allow
     * bootstrapping mechanics that are currently not needed.)
     */
    transient Node<K,V>[] table;

初始化代碼在 final Node<K,V>[] resize() 方法里面,


     Node<K,V>[] newTab = (Node<K,V>[])new Node[newCap];
     table指向這個newTab
查看完整回答
反對 回復 2019-02-12
  • 1 回答
  • 0 關(guān)注
  • 403 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號