Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Java by (3.9k points)

I am currently doing this:

Set<String> setOfTopicAuthors = ....

List<String> list = Arrays.asList( 

    setOfTopicAuthors.toArray( new String[0] ) );

Can you beat this ?

1 Answer

0 votes
by (46k points)

Try:

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

Related questions

0 votes
1 answer
asked Dec 2, 2019 in Java by Anvi (10.2k points)
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
asked Aug 15, 2019 in Java by Krishna (2.6k points)

Browse Categories

...