Javatpoint Logo
Javatpoint Logo

Java String startsWith()

The java string startsWith() method checks if this string starts with given prefix. It returns true if this string starts with given prefix else returns false.


Internal implementation


Signature

The syntax or signature of startWith() method is given below.


Parameter

prefix : Sequence of character


Returns

true or false


Java String startsWith() method example

Test it Now

Output:

true
true

Java String startsWith(String prefix, int offset) Method Example

This is overloaded method of startWith() method which is used to pass one extra argument (offset) to the function. This method works from the passed offset. Let's see an example.

Output:

true
false
true




Help Others, Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA