Most concise way to convert a Set to a List

后端 未结 6 1365
失恋的感觉
失恋的感觉 2020-12-07 12:00

For example, I am currently doing this:

Set setOfTopicAuthors = ....

List list = Arrays.asList( 
    setOfTopicAuthors.toArray(          


        
6条回答
  •  萌比男神i
    2020-12-07 12:13

    Try this for Set:

    Set listOfTopicAuthors = .....
    List setList = new ArrayList(listOfTopicAuthors); 
    

    Try this for Map:

    Map listOfTopicAuthors = .....
    // List of values:
    List mapValueList = new ArrayList(listOfTopicAuthors.values());
    // List of keys:
    List mapKeyList = new ArrayList(listOfTopicAuthors.KeySet());
    

提交回复
热议问题