0
我有一個類的arraylist,當我執行下面的函數時,我有時會得到一個StackOverflowError,我不是100%確定爲什麼,肯定if語句應該排除?它只包含< 500個元素,沒有其他線程擺弄「toCheck」。StackOverflowError當刪除ArrayList對象
if(toCheck.contains(currentConsideration)){
toCheck.remove(currentConsideration);
}
任何幫助將不勝感激!
你可以張貼currentConsideration對象的equals方法? – 2012-03-29 13:18:01
這段代碼看起來不錯。但我懷疑它在循環中使用。你能給我們更多的代碼嗎? – bigGuy 2012-03-29 13:19:26
嘗試刪除'toCheck.contains(currentConsideration)'並僅使用'toCheck.remove(currentConsideration);'。如果存在,它將刪除該元素。 – 2012-03-29 13:20:23