Search code examples
javastring

How to use `string.startsWith()` method ignoring the case?


I want to use string.startsWith() method but ignoring the case.

Suppose I have String "Session" and I use startsWith on "sEsSi" then it should return true.

How can I achieve this?


Solution

  • Use toUpperCase() or toLowerCase() to standardise your string before testing it.