我必須擺脫數組列表中的所有空條目。他們都在最後,因爲我之前調用了刪除方法。因此,當我使用for循環遍歷數組來搜索空節點時(我不確定你稱之爲單個單元格是否令人困惑),但我不能說for(int k = 0; k < arraylist.size(); k++)
之類的東西,因爲尺寸降低了。但我仍然需要擺脫空的節點。我該怎麼做呢?由於刪除數組列表中的空條目
for(int k = 0; k < terms.size(); k++)
{
if((terms.get(k)).length() < 1) // terms is the name of array list and there are null entries at the end of it
terms.remove(k);
}
我不清楚你的問題。你可以發佈你的代碼和錯誤日誌嗎? –
沒有錯誤,但我會發布代碼 – Andrew
你的'ArrayList'的類型是什麼? – msagala25