国产精品天干天干,亚洲毛片在线,日韩gay小鲜肉啪啪18禁,女同Gay自慰喷水

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

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

分享到微博請遵守國家法律
门源| 龙岩市| 同德县| 化州市| 江永县| 兴国县| 页游| 芦山县| 奇台县| 嫩江县| 红桥区| 桦川县| 伽师县| 赞皇县| 黑山县| 榆树市| 五寨县| 平顺县| 松原市| 浙江省| 康马县| 汉源县| 桐乡市| 海安县| 上杭县| 新宾| 临沧市| 太康县| 军事| 华池县| 龙陵县| 长泰县| 巴林左旗| 宝丰县| 镇坪县| 德格县| 达尔| 九龙城区| 顺平县| 塔城市| 民丰县|