startsWith( ) method determines whether a given string starts with a specified string. (example- determines whether Sunny string starts with Sun string)
endsWith( ) method determines whether a given string ends with a specified string. (example- determines whether Starfish string ends with fish string)
Lets implement this on Eclipse IDE:
1. Create startsWithendsWithDemo class under any project as shown below:
3. Observe that the output is displayed in the console as shown below:
Click here to download the project containing the class files used in this post (You can download this project and import into Eclipse IDE on your machine)
Please comment below to feedback or ask questions.
Using CompareTo( ) method will be explained in the next post.