最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

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

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

分享到微博請遵守國家法律
抚远县| 囊谦县| 阜康市| 砀山县| 博爱县| 大悟县| 五大连池市| 石棉县| 荥阳市| 浮山县| 托里县| 北宁市| 新源县| 双牌县| 苏尼特右旗| 永靖县| 定安县| 和龙市| 渭南市| 崇仁县| 巩留县| 怀柔区| 中牟县| 泸溪县| 浦北县| 建昌县| 洪雅县| 宝坻区| 东至县| 旺苍县| 积石山| 巩义市| 禹城市| 拉孜县| 来宾市| 寻甸| 固镇县| 博罗县| 水富县| 皮山县| 五原县|