String []array &#61;newString[]{"A","B","C"};{System.out.println("数组排序");Arrays.sort(array);for(String r : array){System.out.println(r);}}{System.out.println("数组转List");for(String r : Arrays.asList(array)){System.out.println(r);}}{System.out.println("List转数组");List<String> list &#61; Arrays.asList(array);for(String r : list.toArray(newString[list.size()])){System.out.println(r);}}{System.out.println("数组转成set集合");Set<String> set &#61;newHashSet<>(Arrays.asList(array));System.out.println(set);}{System.out.println("数组转字符串&#xff0c;以逗号隔开");String s &#61; StringUtils.join(array,",");System.out.println(s);}{System.out.println("数组转字符串&#xff0c;以单引号及逗号分开&#xff0c;一般用于SQL拼IN串");String s &#61; StringUtils.join(array,"\&#39;,\&#39;");String s1 &#61; StringUtils.wrap(s,"\&#39;");System.out.println(s1);}
输出结果&#xff1a;
数组排序 A B C 数组转List A B C List转数组 A B C 数组转成set集合 [A, B, C] 数组转字符串&#xff0c;以逗号隔开 A,B,C 数组转字符串&#xff0c;以单引号及逗号分开&#xff0c;一般用于SQL拼IN串 &#39;A&#39;,&#39;B&#39;,&#39;C&#39;