String 转 String数组:
String str = "hello";
String[] split = str.split("");
String 首字母转大写:
public static String captureName(String name) {
// name = name.substring(0, 1).toUpperCase() + name.substring(1);
// return name;
char[] cs=name.toCharArray();
cs[0]-=32;
return String.valueOf(cs);
}
字符串替换:
public static void main(String[] args) {
String str = "hello %s";
String format = String.format(str, "world");
System.out.println(format);
}
输出:
Connected to the target VM, address: '127.0.0.1:50025', transport: 'socket'
hello world
Disconnected from the target VM, address: '127.0.0.1:50025', transport: 'socket'
Process finished with exit code 0
网友评论