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