将字符串数组放进ArrayList中,怎么判断长度

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()
温馨提示:答案为网友推荐,仅供参考

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网