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

為了賬號(hào)安全,請及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

數(shù)組跟list的使用

數(shù)組跟list的使用

紅糖糍粑 2019-01-18 09:16:03
Person[] p = new Person[10];//Person是自定義的一個(gè)類型 ArrayList<Person> pList = new ArrayList<Person>(); 上邊的p跟pList都能用來存放person類型的數(shù)據(jù),怎么選擇?ArrayList可以實(shí)現(xiàn)的功能數(shù)組也能實(shí)現(xiàn),為啥會(huì)有ArrayList呢?
查看完整描述

1 回答

?
慕桂英546537

TA貢獻(xiàn)1848條經(jīng)驗(yàn) 獲得超10個(gè)贊

ArrayList底層就是Object數(shù)組
 transient Object[] elementData
不過它可以動(dòng)態(tài)擴(kuò)容,這是它的擴(kuò)容方法
 private void grow(int minCapacity) {
        // overflow-conscious code
        int oldCapacity = elementData.length;
        int newCapacity = oldCapacity + (oldCapacity >> 1);
        if (newCapacity - minCapacity < 0)
            newCapacity = minCapacity;
        if (newCapacity - MAX_ARRAY_SIZE > 0)
            newCapacity = hugeCapacity(minCapacity);
        // minCapacity is usually close to size, so this is a win:
        elementData = Arrays.copyOf(elementData, newCapacity);
    }
查看完整回答
反對 回復(fù) 2019-03-01
  • 1 回答
  • 0 關(guān)注
  • 461 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

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