你可以使用 Java 中的 HashSet 类将字符串数组转换为 Set。
首先,需要创建一个 HashSet 对象:
Set<String> set = new HashSet<>();
然后,可以使用 Set 类的 addAll 方法将字符串数组中的所有元素添加到 Set 中:
String[] array = {"a", "b", "c"};
set.addAll(Arrays.asList(array));
现在,Set 对象中应包含字符串数组中的所有元素。
注意,如果希望 Set 中不包含重复元素,可以使用 HashSet,因为它不允许添加重复元素。如果希望保留字符串数组中的所有元素,并且允许重复元素,则可以使用 LinkedHashSet 或 TreeSet。