IndexOutOfBoundException在队列中添加时
问题描述:
private void removeQueue(Queue queue)
{
queue.setTodoDeleted(false);
if (queueIndex != -1) {
this.queueList.add(queueIndex , queue);
mItemManger.closeAllItems();
}
}
其中queueList是ArrayList的queue
ArrayList queuelist
。IndexOutOfBoundException在队列中添加时
问题:索引为2和列表大小为1,同时加入在queueList所以,IndexOutOfBoundException
抛出在线路this.queueList.add(queueIndex , queue)
。
避免这种情况的最佳方法是什么?在先进的感谢
'queueIndex'来自哪里?它应该遵循'队列'大小... – AxelH
索引是2并且列表大小是1,您正试图获取不存在的元素 – Venkat