转换Set< T>的最简洁方法到列表< T> [英] Most concise way to convert a Set<T> to a List<T>

查看:77
本文介绍了转换Set< T>的最简洁方法到列表< T>的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如,我目前正在这样做:

For example, I am currently doing this:

Set<String> setOfTopicAuthors = ....

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

你能打败这个吗?

推荐答案

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

这篇关于转换Set&lt; T&gt;的最简洁方法到列表&lt; T&gt;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆