前言
定义和用法endsWith() 方法检查字符串是否以指定字符结尾。提示:请使用 startsWith() 方法检查字符串是否以指定字符开头。实例判断字符串是否以
定义和用法
endsWith() 方法检查字符串是否以指定字符结尾。
提示:请使用 startsWith() 方法检查字符串是否以指定字符开头。
实例
判断字符串是否以指定字符结尾:
String myStr = "Hello";
System.out.println(myStr.endsWith("Hel")); // false
System.out.println(myStr.endsWith("llo")); // true
System.out.println(myStr.endsWith("o")); // true
运行实例 »
点击 "运行实例" 按钮查看在线实例
语法
public boolean endsWith(String chars)
运行实例 »
点击 "运行实例" 按钮查看在线实例
参数
| 参数 | 描述 |
|---|---|
| chars |
String,表示要检查的字符。 |
技术细节
| 返回: |
true - 如果字符串以指定字符结尾
false - 如果字符串不以指定字符结尾
|
|---|
