ArrayList Retrieve object by Id

后端 未结 7 536
别跟我提以往
别跟我提以往 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:17

    A better way to do this would be to use a Map.

    In your case, you could implement it in the following way

        Map
    

    you can use the "get" method to retrieve the appropriate account object.

        accountMap.get(id);
    

提交回复
热议问题