使用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
}
}