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)
Welcome to Intellipaat Community. Get your technical queries answered by top developers!

30.5k questions

32.5k answers

500 comments

108k users

Browse Categories

...