Java String endsWith() 方法
示例
判断字符串是否以指定字符结束
String myStr = "Hello";
System.out.println(myStr.endsWith("Hel")); // false
System.out.println(myStr.endsWith("llo")); // true
System.out.println(myStr.endsWith("o")); // true
定义和用法
endsWith()
方法检查字符串是否以指定字符或字符序列结束。
提示:使用 startsWith() 方法检查字符串是否以指定字符或字符序列开头。
语法
public boolean endsWith(String chars)
参数值
参数 | 描述 |
---|---|
chars | 一个 String ,表示要检查的字符或字符序列 |
技术详情
返回 | 一个 boolean 值
|
---|
❮ String Methods