表达式的类型必须是数组类型,但它解析为ArrayList <integer>

时间:2015-07-12 04:24:38

标签: java arrays arraylist

我试图将this === '2'放入ints,但Eclipse指向错误: Arraylist myList

我尝试将原始类型转换为Object类型但仍然遇到相同的错误。 COuld smb请帮帮我吗?

The type of the expression must be an array type but it resolved to ArrayList<Integer>

1 个答案:

答案 0 :(得分:4)

您无法使用此语法从列表中获取元素。

myList[i]

仅对数组有效。相反,使用

myList.get(i);

方法。更有可能的是你想把myArray[i]放在那里。