2017-05-08 38 views

回答

0

我可以給你一個創建一個數組列表的例子,然後循環遍歷它的總長度,如果這是你正在尋找的。

import java.util.ArrayList; 
import java.util.List; 

public void arrayListTest() { 
    List<String> al = new ArrayList<>(); 
    al.add("Hello this is 0 in the ArrayList"); 
    al.add("G'Day this is 1 in the ArrayList"); 
    al.add("Auf Wiedersehen this in 2 in the ArrayList signing out"); 

    for (Integer i=0;i<al.size();i++) { 
     System.out.println(al.get(i)); 
    } 
} 

這應該輸出:

Hello this is 0 in the ArrayList 
G'Day this is 1 in the ArrayList 
Auf Wiedersehen this in 2 in the ArrayList signing out 

欲瞭解更多信息,請參閱Oracle數據庫ArrayLists