String转set<String>
时间: 2023-11-02 14:24:38 浏览: 94
String 转换类
要将String数组转换为Set<String>,您可以使用以下代码:
String[] string = new String[]{"data"};
Set<String> set = new HashSet<String>(Arrays.asList(string));
这段代码会先将String数组转换为List<String>,然后通过构造函数将List<String>转换为Set<String>。<span class="em">1</span><span class="em">2</span><span class="em">3</span><span class="em">4</span>
#### 引用[.reference_title]
- *1* *2* *3* *4* [Java Map,List,Set,String[]之间的转换](https://blog.csdn.net/qq_41834553/article/details/122558230)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 100%"]
[ .reference_list ]
阅读全文