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

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

list的get方法index輸入的是要索引的字段,和得出的結(jié)果不對(duì)啊,索引應(yīng)該沒(méi)有寫(xiě)錯(cuò)啊

public void testadd() {

?

?//創(chuàng)建一個(gè)課程對(duì)象,并通過(guò)調(diào)用add方法,添加到備選課程list中

?

?Course cr1=new Course("1","數(shù)據(jù)結(jié)構(gòu)");

?coursetoselect.add(cr1);

?Course temp=(Course) coursetoselect.get(0);

?System.out.println("添加了課程"+temp.id+":"+temp.name );

?

?

?Course cr2=new Course("2","C語(yǔ)言");

?coursetoselect.add(0,cr2);

?Course temp1=(Course)coursetoselect.get(0);

?System.out.println("添加了課程"+temp1.id+":"+temp1.name );

?

?coursetoselect.add(cr1);

?Course temp0=(Course) coursetoselect.get(1);

?System.out.println("添加了課程"+temp0.id+":"+temp0.name );

?//以下方法會(huì)拋出數(shù)組下標(biāo)越界異常

// ? ? ?Course cr3=new Course("3","test");

// ? ? ?coursetoselect.add(4,cr3);

?

?Course[] course= {new Course("3","離散數(shù)學(xué)"),new Course("4","匯編語(yǔ)言")};

?coursetoselect.addAll(Arrays.asList(course));

?Course temp2=(Course) coursetoselect.get(2);

?Course temp3=(Course) coursetoselect.get(3);


System.out.println("添加了兩門(mén)課程"+temp2.id+":"+temp2.name+";"+temp3.id+":"+temp3.name);

?Course[] course2= {new Course("5","高等數(shù)學(xué)"),new Course("6","大學(xué)英語(yǔ)")};

?coursetoselect.addAll(2,Arrays.asList(course2));

?

?Course temp4=(Course) coursetoselect.get(4);

?Course temp5=(Course) coursetoselect.get(5);

?System.out.println("添加了兩門(mén)課程"+temp4.id+":"+temp4.name+";"+temp5.id+":"+temp5.name);

?}


?

? ?得出的結(jié)果

添加了課程1:數(shù)據(jù)結(jié)構(gòu)

添加了課程2:C語(yǔ)言

添加了課程1:數(shù)據(jù)結(jié)構(gòu)

添加了兩門(mén)課程1:數(shù)據(jù)結(jié)構(gòu);3:離散數(shù)學(xué)

添加了兩門(mén)課程1:數(shù)據(jù)結(jié)構(gòu);3:離散數(shù)學(xué)


正在回答

2 回答

你是一輸入就輸出了,你說(shuō)呢?都添加好,在輸出就不會(huì)了。

0 回復(fù) 有任何疑惑可以回復(fù)我~
#1

qq_Justcomplete_04021004 提問(wèn)者

非常感謝!
2017-08-02 回復(fù) 有任何疑惑可以回復(fù)我~

temp2和temp3按順序后面應(yīng)該是get(3)、get(4)

0 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消

list的get方法index輸入的是要索引的字段,和得出的結(jié)果不對(duì)啊,索引應(yīng)該沒(méi)有寫(xiě)錯(cuò)啊

我要回答 關(guān)注問(wèn)題
微信客服

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

幫助反饋 APP下載

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

公眾號(hào)

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