Java StringendsWith() Method
Example
Find out if the string ends with the specified characters:
String myStr = "Hello";System.out.println(myStr.endsWith("Hel")); // falseSystem.out.println(myStr.endsWith("llo")); // trueSystem.out.println(myStr.endsWith("o")); // trueDefinition and Usage
TheendsWith() method checks whether a string ends with the specified character(s).
Tip: Use thestartsWith() method to check whether a stringstarts with the specified character(s).
Syntax
public boolean endsWith(Stringchars)Parameter Values
| Parameter | Description |
|---|---|
| chars | AString, representing the character(s) to check for |
Technical Details
| Returns: | Aboolean value:
|
|---|
❮ String Methods

