字符串反转
StringBuffer 或 StringBuilder 的 reverse方法
String s1 = new StringBuilder(str).reverse().toString();
String s3 = new StringBuffer(str).reverse().toString();
System.out.println(s1);//cba
System.out.println(s3);//cba
List集合拼接成逗号分隔的字符串
List<String> listStr = Arrays.asList("a", "b", "c");
//String自带方式
String s2 = String.join(",", listStr);
System.out.println(s2);//a,b,c
Maven依赖
<!--String 工具类-->
<dependency><groupId>org.apache.commons</groupId><artifactId>commons-lang3</artifactId><version>3.12.0</version>
</dependency>
首字母转大写
String str = "abc";
String capitalize = StringUtils.capitalize(s);
System.out.println(capitalize);//Abc
重复拼接字符串
//重复拼接字符串
String str1 = StringUtils.repeat("abc", 2);
System.out.println(str1);//abcabc