startsWith() - String Methods in Java


This article is a part of String Methods in Java.
The startsWith() method checks whether the string starts with the specified characters. The parameter passed in this method is String.


Return type

The return type for startsWith() method is Boolean value. It returns true if the string starts with the specified characters and false otherwise.
Let us look at an example.


Output

Let us look at the output of the above.

String Methods startsWith()
Fig.1- String Method - startsWith()

endsWith()

The endsWith() method checks whether the string ends with the specified characters. The parameter passed in this method is String.

Return type

The return type for endsWith() method is Boolean value. It returns true if the string ends with the specified characters and false otherwise.
Let us look at an example.


Output

Let us look at the output of the above.

String Methods endsWith()
Fig.2- String Method - endsWith()

Read More

Author : Satyam Kumar -



You will also like: