Existing Code:
Map<?, ?> rolePrincipleMap = cnRoleHolder.getRolePrincipalMap();
Iterator<?> cnRoleIterator = rolePrincipleMap.keySet().iterator();
while (cnRoleIterator.hasNext()) {
Object cnRole = cnRoleIterator.next();
if (!SUBMITTER.equals(cnRole.toString())) {
ArrayList<?> cnRoleMembersList = (ArrayList<?>) rolePrincipleMap.get(cnRole);
//operations
}}
Error is in line where ArraList is defined. Pls help to update the code.
That error warns you that you are accessing the map to retrieve all the keys, and then for some keys, you access the map again to retrieve the value. It is more efficient to retrieve the entries of the map, as each entry has the key and value already: