Computer Science, asked by kimtaenik, 1 year ago

How does endsWith () and startswith () differ? Explain with examples. ​

Answers

Answered by SaniaFatima2006
8

First difference

The startsWith() method is used to check if a string starts with a given string.

The endsWith() method is used to check if a string ends with a given string. In a way, endsWith() can be used to check the extension of a file. 

Secon difference

endsWith() method returns tests if this string ends with the specified suffix. 

startsWith() method returns tests if this string starts with the specified prefix. 

Similar questions