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

