简体   繁体   中英

How to iterate multiple arraylist

In my application 2 Arraylists are there:

1) rejectedList  - employees info whose status is rejected
2) acceptedList  - employees info whose staus is accepted 

those 2 Arraylists are added to one mainList and returned.

i need to iterate mainList , seperate those 2 lists and set to new 2 arraylists

    while(rs.next()) {

      UserDTO userDTO = new UserDTO();  
      // getting values from db

      userDTO.setUserKey(UserKey);
      userDTO.setGroupId(bankGroupId);
      userDTO.setDisplayUserId(displayUserId);
      userDTO.setStatus(status);

      if(status.equalsIgnoreCase("Reject")){
        rejectedList.add(UserDTO);
      } else if (status.equalsIgnoreCase("Accept")) {
        acceptedList.add(UserDTO);
      }
    }

  mainList.add(rejectedList;
  mainList.add(acceptedList)
  return mainList;

So really you just want to sort the main list into two sections, based on the accepted/rejected attribute? If this is the case you may want to use a map.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM