使用startsWith與endsWith需注意的點
- 字符串不能顛倒
- 字符串需要判空
public class Test {
public static void main(String[] args) {
String a = "hello world";
String b = "world";
String c = "";
LogJava.e(a.endsWith(b) + ""); //正常使用 true
LogJava.e(a.endsWith(c) + ""); //c爲空字符串 true
LogJava.e(a.startsWith(c) + "");//c爲空字符串 true
}
}