How to efficiently (performance) remove many items from List in Java?

后端 未结 12 644
迷失自我
迷失自我 2021-01-31 09:00

I have quite large List named items (>= 1,000,000 items) and some condition denoted by that selects items to be deleted and is true for many (maybe hal

12条回答
  •  别那么骄傲
    2021-01-31 09:40

    One thing you could try is to use a LinkedList instead of an ArrayList, as with an ArrayList all other elements need to be copied if elements are removed from within the list.

提交回复
热议问题