Is the Contains Method in java.lang.String Case-sensitive?

Posted by Kamikaze Mercenary on Stack Overflow See other posts from Stack Overflow or by Kamikaze Mercenary
Published on 2008-09-17T19:37:32Z Indexed on 2010/04/15 16:33 UTC
Read the original article Hit count: 338

Filed under:
|

Say I have 2 strings,

String s1 = "AbBaCca";
String s2 = "bac";

I want to preform a check returning that s2 is contained within s1. I can do this with:

return s1.contains(s2);

I am pretty sure that contains() is case sensitive, however I can't determine this for sure from reading the documentation. If it is then I suppose my best method would be something like:

return s1.toLowerCase().contains(s2.toLowerCase());

All this aside, does anyone know of another (possibly better) way to accomplish this without caring about case-sensitivity?

© Stack Overflow or respective owner

Related posts about java

Related posts about string