0

在我的代码中,我编写了一个函数来获取一个特定商店的所有条目。我的查询返回所有条目,在这些条目中迭代后,我使用导入参数状态删除查询。

条目以更正的形式排序。删除第一个元素后,迭代器从底部开始,排序从 ZtoA 开始,而不是从 AtoZ 开始。

Collection col; 
col = recallStoreHome.findByStoreId(storeid);

for (Iterator it = col.iterator(); it.hasNext();) {
                RecallStoreEntityLocal recallStore =(RecallStoreEntityLocal) it.next();
                Recall recall = this.getRecall(recallStore.getRecallid());
                if(!recallStatus.equalsIgnoreCase(recall.getStatus()))
                {
                    it.remove();
                }
}


Iterator before: [a, b, c, d, e, f]
Iterator after : [a, f, e, d, c, b]

是否可以保留排序?

结果应该是:[a, b, c, d, e, f]

4

0 回答 0