[英]How to get values of a table by ArrayList of ArrayList
我對此有疑問。 我有2個:
ArrayList<ArrayList<String>> database = new ArrayList<ArrayList<String>>();// to save each row into database
>ArrayList<String> rows = new ArrayList<String>(); to save each line in to arraylist.
之后,我想在每個列中獲取一個值,如下所示:
1 2 3 4 5 6
a f b 4 5 5
3 3 5 6 1 8
我期望的是:
1 a 3
2 f 3
這是我的代碼:
String[] values = line.split(",");
for (String s: values )
rows.add(s);
database.add(rows;)
我怎樣才能得到預期的結果?
String[] values = line.split(",")
for (int i = 0; i < values.length; i++) {
database.get(i).add(values[i])
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.