1、String可以和char数组、byte数组互换
String s =
"abc";
char[] charArr = s.toCharArray();
byte[] byteArr = s.getBytes();
String s1 =
new String(charArr);
String s3 =
String.valueOf(charArr);
String s2 =
new String(byteArr);
2、字符串倒序
String s =
"abc";
StringBuilder sb =
new StringBuilder(s);
sb = sb.reverse();
System.
out.println(sb);
//将StringBuilder转换成
String
String s4= sb.toString();
String s5 =
String.valueOf(sb);
转载请注明原文地址: https://ju.6miu.com/read-700264.html