- 获取指定位置的字符
- 判断数组是否为空
- 转换大小写
- 将字符串首位部的空白省略输出
- 转换大小写
- 比较大小
- 截取指定位置的字符串
package StringClassUse;
import org.junit.Test;
public class StringMethod {
@Test
public void test(){
String s="Hello";
System.out.println(s.charAt(2));
String s1="";
System.out.println(s1.isEmpty());
System.out.println(s.toLowerCase());
System.out.println(s.toUpperCase());
String s2=" he llo";
String s3=s2.trim();
System.out.println(s3);
System.out.println(s.equals(s1));
System.out.println(s.equalsIgnoreCase(s));
String s4="abc";
String s5="abe";
System.out.println(s4.compareTo(s5));
String s6="何似在人间";
System.out.println(s6.substring(2));
System.out.println(s6.substring(2,4));
}
}
运行结果
l
true
hello
HELLO
he llo
false
true
-2
在人间
在人