Convert Set to List without creating new List

前端 未结 15 957
鱼传尺愫
鱼传尺愫 2020-12-07 06:43

I am using this code to convert a Set to a List:

Map> mainMap = new HashMap<>();

for (int i         


        
15条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-07 07:30

    I found this working fine and useful to create a List from a Set.

    ArrayList < String > L1 = new ArrayList < String > ();
    L1.addAll(ActualMap.keySet());
    for (String x: L1) {
        System.out.println(x.toString());
    }
    

提交回复
热议问题