Search code examples
javalistcollectionssetjava-6

Most concise way to convert a Set<T> to a List<T>


For example, I am currently doing this:

Set<String> setOfTopicAuthors = ....

List<String> list = Arrays.asList( 
    setOfTopicAuthors.toArray( new String[0] ) );

Can you beat this ?


Solution

  • List<String> list = new ArrayList<String>(listOfTopicAuthors);