Select object from ARRAYLIST WITHOUT LOOP - ANDROID

后端 未结 3 1207
眼角桃花
眼角桃花 2021-01-24 22:31

I am looking for a library which can select object from ArrayList like SQL \"where\" command.

I have huge arraylists (between 2000 and 20000) in my project and i don\'t

3条回答
  •  无人共我
    2021-01-24 23:14

    If you want to select an element that matches a criteria (or elementS that will match), use the Java 8 filter function. (no need to use other libraries anymore).

    Do it as:

    List listOfFoo = ...
    Stream matchingFoo = listOfFoo.stream().filter(t -> t.propertyOrMethod == 'criteria');
    

提交回复
热议问题