java の endsWith メソッドの使用方法
文字列が指定した末尾で終わるかどうかを判定するもので Javaの endWith() 関数です。
String str = "Hello, World!";
// 判断字符串是否以指定的后缀结束
boolean endsWithExclamation = str.endsWith("!"); // true
boolean endsWithComma = str.endsWith(","); // false
System.out.println(endsWithExclamation);
System.out.println(endsWithComma);
上の例では、関数 `endsWith()` は文字列 `str` が ! または, で終わるか判定します。結果は、文字列 `str` が ! で終わる (真) が、, で終わらない (偽) ことを示しています。