Java文字列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)
パラメータ値
Parameter | Description |
---|---|
chars | A String , representing the character(s) to check for |
技術的な詳細
戻り値: | boolean 値
:
|
---|
❮文字列メソッド