substring(0) 从0的位置进行截取,包裹【0,n】
b.substring(1, 5) 截取 【1,5)
a.concat(b) 链接二个字符串abc01234567d9
c.replace(‘a’, ‘u’) 将所有的a换成u
String e = “abc”;
e.toUpperCase()是小写转换成大写
f.trim()去除首尾空格
public class substring方法 {
public static void main(String[] args) {
String a="abc";
String b="01234567d9";
System.out.println("b的长度:"+b.length());
System.out.println(b.substring(0));
System.out.println(b.substring(0, 5));
System.out.println(a.concat(b));
String c="l am a apple";
System.out.println(c.replace('a', 'u'));
//
String d = "a-b-c-d-e-f";
d.split("-");
//
System.out.println("e.toUpperCase()是小写转换成大写");
String e = "abc";
System.out.println(e.toUpperCase());
System.out.println("toLowerCase()是大写转小写");
System.out.println(e.toUpperCase().toLowerCase());
System.out.println("f.trim()去除首尾空格");
String f=" a b c ";
System.out.println(f.trim());
//转换为string类型
String g="false";
System.out.println(String.valueOf("true"));
}
}
运行结果: