Map<String, List> mainMap = new HashMap<String, List>();
for(int i=0; i<something.size(); i++){
Set set = getSet(...); //return different result each time
List listOfNames = new ArrayList(set);
mainMap.put(differentKeyName,listOfNames);
}
It's a code that changes Set to List, but I don't want to create a list every time I go around the loop, so what should I do?
performance list java set
mainList.addAll(set);
You can use the List.addAll() method like this.
© 2024 OneMinuteCode. All rights reserved.