五月天青色头像情侣网名,国产亚洲av片在线观看18女人,黑人巨茎大战俄罗斯美女,扒下她的小内裤打屁股

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

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的操作的評論 (共 條)

分享到微博請遵守國家法律
蒲江县| 化德县| 颍上县| 黄骅市| 封丘县| 无锡市| 上虞市| 丰顺县| 汶川县| 眉山市| 安顺市| 渝北区| 天峨县| 措美县| 清镇市| 新丰县| 百色市| 海南省| 安福县| 富源县| 鹤山市| 济源市| 菏泽市| 潜江市| 宁海县| 金乡县| 合山市| 盐山县| 青岛市| 固始县| 鄂尔多斯市| 苗栗县| 广河县| 京山县| 太仆寺旗| 玉树县| 陆丰市| 文山县| 泰州市| 固阳县| 盈江县|