[英]How to get values of a table by ArrayList of ArrayList
I have a matter with this. 我对此有疑问。 I Have 2 this:
我有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.
After that, I want to get a values into every column, like this: 之后,我想在每个列中获取一个值,如下所示:
1 2 3 4 5 6
a f b 4 5 5
3 3 5 6 1 8
Expected I want is: 我期望的是:
1 a 3
2 f 3
Here is my code: 这是我的代码:
String[] values = line.split(",");
for (String s: values )
rows.add(s);
database.add(rows;)
How could I do the get the expected result? 我怎样才能得到预期的结果?
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.