我必须摆脱数组列表中的所有空条目。他们都在最后,因为我之前调用了删除方法。因此,当我使用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