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() 报错
Cannot invoke length() on the array type String[]
((String[])a.get(i)).length()