数学教育专业博士:将字符串数组放进ArrayList中,怎么判断长度

来源:百度文库 编辑:高考问答 时间:2024/05/01 00:41:24
ArrayList a=new ArrayList();
a.add(form.getCheckbox1());
a.add(form.getCheckbox2());
a.add(form.getCheckbox2());
a.add(form.getCheckbox3());
a.add(form.getCheckbox4());
a.add(form.getCheckbox5());
a.add(form.getCheckbox6());
a.add(form.getCheckbox7());
a.add(form.getCheckbox8());
for(int i=1,j=1;i<=8;i++)
{
if((!a.get(i).equals("")))
{
x[j]=a.get(i).length();
j++;
}
}
这句话a.get(i).length();报错
The method length() is undefined for the type Object

用什么方法知道放在ArrayList中字符串数组的长度,那个size也不行

Checkbox1是String[]类型的!
int x[]=new int[100];

(String)a.get(i).length(); 方法不行!报错
Type mismatch: cannot convert from String to int

(String)a.get(i).length();