ArrayList Retrieve object by Id

后端 未结 7 510
别跟我提以往
别跟我提以往 2020-12-16 12:49

Suppose I have an ArrayList of my custom Objects which is very simple. For example:

class Account
{
public String Name;
public In         


        
相关标签:
7条回答
  • 2020-12-16 13:36

    Simple Solution:

    Account account = accountList.stream().filter(a -> a.getId() == YOUR_ID).collect(Collectors.toList()).get(0);
    
    0 讨论(0)
提交回复
热议问题