How to convert Set to String[]?

前端 未结 7 1880
栀梦
栀梦 2020-11-28 19:12

I need to get a String[] out of a Set, but I don\'t know how to do it. The following fails:

Map myMa         


        
7条回答
  •  Happy的楠姐
    2020-11-28 19:31

    Guava style:

    Set myset = myMap.keySet();
    FluentIterable.from(mySet).toArray(String.class);
    

    more info: https://google.github.io/guava/releases/19.0/api/docs/com/google/common/collect/FluentIterable.html

提交回复
热议问题