我在将对象的 Arraylist 转换为二维数组时遇到了一些麻烦。arrayList ar 包含许多名为 Row 的对象。每行包含许多字符串。我希望能够通过arrayList,访问每一行并将字符串存储在一个数组中。如果这没有意义,我真的很抱歉。我什至觉得很难解释!这是我到目前为止所拥有的:
public String tableArray[][]; //Array of every applicant
private ArrayList<Row> ar;
private Row r;
public void display()
{
int i, j;
for (Row r: ar)
i = 0;
for(String s: r)
{
tableArray = new String[i][j];
j++;
}
i++;
}
这是 Row 类
import java.util.ArrayList;
import java.lang.String;
public class Row
{
private String appNumber;
private String name;
private String date;
private String fileLoc;
private String country;
private String elementString;
public String results[];
public Row(String appNumber, String name, String date, String fileLoc, String country, Table table)
{
this.appNumber = appNumber;
this.name = name;
this.date = date;
this.fileLoc = fileLoc;
this.country = country;
asAString();
table.addApplicant(this);
}
public void asAString()
{
String elementString = appNumber +","+ name +","+ date +","+ fileLoc +","+ country;
results = elementString.split(",");}
}
谢谢你们的帮助