135. Using startsWith( ) and endsWith( ) methods

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:

2. Save and Run the 'startsWithendsWithDemo' class
3. Observe that the output is displayed in the console as shown below:

Download this project:

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.

1 comment:

2400 Waheed Ahmed said...

I'm stuck with you see id of username field keeps on changing every time you run the Selenium script due to which it fails test case. How can this be solved?

Can you provide the reg expression for it?

Every time page is refreshed it changes you may try as well.