【发布时间】:2013-12-03 12:36:03
【问题描述】:
我正在尝试创建一种将链表转换为数组列表的方法。
public ArrayList<Integer> toList(){
//Node node;
Node current = node;
while(current != null){
current = current.next;
array.add(current.val);
}
}
下面显示错误
no suitable method found for add(Object)
method ArrayList.add(int,Integer) is not applicable
(actual and formal argument lists differ in length)
method ArrayList.add(Integer) is not applicable
(actual argument Object cannot be converted to Integer by method invocation conversion)
我目前正在使用 JDK 1.7,从我在这个论坛上找到的内容来看,JDK 1.7 应该可以很好地解决这个问题。会有什么问题?
【问题讨论】:
标签: java arraylist linked-list