Convert Set to List without creating new List

前端 未结 15 951
鱼传尺愫
鱼传尺愫 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:21

    the simplest solution

    I wanted a very quick way to convert my set to List and return it, so in one line I did

     return new ArrayList(mySetVariable);
    

提交回复
热议问题