Sheetal Bhatewara Sheetal Bhatewara - 1 month ago 6
Java Question

startsWith() method of string ignoring case

I want to use

startsWith()
method of
String
but ignoring the case.

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

Answer

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