String a1 = "Hello";
//获取字符串首尾字符
System.out.println(a1.charAt(0)); //H
System.out.println(a1.charAt(a1.length()-1)); //o
//判断字符串首尾字符
System.out.println(a1.startsWith("H")); //true
System.out.println(a1.endsWith("o")); //true
Java基础:获取String字符串首尾字符,判断字符串首尾字符
最新推荐文章于 2023-04-03 16:12:32 发布