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

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

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

分享到微博請遵守國家法律
鄂州市| 东乡族自治县| 武山县| 镇赉县| 遂川县| 上林县| 贡嘎县| 金阳县| 确山县| 上饶县| 罗源县| 宁化县| 大庆市| 开远市| 嘉禾县| 梁平县| 静安区| 新闻| 渭南市| 资源县| 海伦市| 乌鲁木齐市| 宾川县| 台前县| 温泉县| 兴安县| 景东| 祥云县| 九龙城区| 康定县| 同江市| 青神县| 宁夏| 莱芜市| 江口县| 奈曼旗| 新巴尔虎左旗| 博罗县| 雅安市| 威信县| 黔东|