无码av一区二区三区无码,在线观看老湿视频福利,日韩经典三级片,成 人色 网 站 欧美大片在线观看

歡迎光臨散文網 會員登陸 & 注冊

Arraylist的操作

2023-03-08 19:35 作者:終極向晚葵  | 我要投稿

package notebook;


import java.util.ArrayList;


public class NoteBook {

private ArrayList<String> notes =new ArrayList<String>();

public void add(String s) {

notes.add(s);

}

public void add(int location,String s) {

notes.add(location,s);

}

public int getSize(){

return notes.size();

}

public String getNote(int index) {

return notes.get(index);

}

//index,下標

public void removeNote(int index) {

notes.remove(index);

}

public String []list(){

String []a=new String[notes.size()];

//for(int i=0;i<notes.size();i++) {

//a[i]=notes.get(i);

//}

notes.toArray(a);//此函數(shù)的作用與上面的注解相同

return a;

}

public static void main(String[] args) {

// TODO Auto-generated method stub

NoteBook nb =new NoteBook();

nb.add("first");

nb.add("second");

nb.add(1,"third");

System.out.println(nb.getSize());

System.out.println(nb.getNote(0));

System.out.println(nb.getNote(1));

nb.removeNote(1);

String[]a =nb.list();

for(String s:a) {//對于a里面的每一個String s 來說

System.out.println(s);

}

}


}


Arraylist的操作的評論 (共 條)

分享到微博請遵守國家法律
潞城市| 磐石市| 洛浦县| 菏泽市| 厦门市| 明水县| 孟村| 紫阳县| 青铜峡市| 东平县| 嵊泗县| 永兴县| 若尔盖县| 阿尔山市| 沙雅县| 中山市| 阿坝县| 秦安县| 威远县| 大足县| 门头沟区| 嘉定区| 舞阳县| 探索| 荥阳市| 汝阳县| 沐川县| 深州市| 丽水市| 定州市| 班戈县| 郑州市| 辽宁省| 原平市| 乌鲁木齐县| 威海市| 古交市| 天等县| 旬邑县| 赤壁市| 防城港市|