新聞中心
這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷解決方案
ArrayList的陷阱!誰(shuí)知道?
- import java.util.ArrayList;
- public class ArrayListTest {
- public static void main(String[] args) {
- //一個(gè)物件鏈表
- ArrayList strAl= new ArrayList ();
- strAl.add("a");
- strAl.add("b");
- strAl.add("c");
- strAl.add("d");
- //要?jiǎng)h除物件鏈表的所有索引
- ArrayList indexes= new ArrayList ();
- indexes.add(0);
- indexes.add(2);
- //逐個(gè)刪除
- for (int i = 0; i < indexes.size(); i++) {
- strAl.remove(indexes.get(i));
- }
- //打印***物件個(gè)數(shù)
- System.out.println(strAl.size());
- }
- }
- //誰(shuí)能不運(yùn)行代碼,知道打印出來(lái)是多少呢
網(wǎng)站欄目:ArrayList的陷阱!誰(shuí)知道?
路徑分享:http://fisionsoft.com.cn/article/dhcogej.html


咨詢
建站咨詢
