I am using this code to convert a Set
to a List
:
(我正在使用此代码将Set
转换为List
:)
Map<String, List> mainMap = new HashMap<String, List>();
for(int i=0; i<something.size(); i++){
Set set = getSet(...); //returns different result each time
List listOfNames = new ArrayList(set);
mainMap.put(differentKeyName,listOfNames);
}
I want to avoid creating a new list in each iteration of the loop.
(我想避免在循环的每次迭代中创建一个新列表。)
Is that possible?(那可能吗?)
ask by Muhammad Imran Tariq translate from so