[SalesForce] String method startsWith(String) is case-sensitive or not

When i tried to run the following code snippet anonymously in dev console i got different boolean results. Is string method startsWith(String) case-sensitive or not?

String s1 = 'Thomas Inc';
System.debug(s1.startswith('ThoMas'));

It returns false when i changed some letters to upper case. Do i have to convert the source and the comparison string to any of the cases before comparing? Do we have case-insensitive version of this method? Please advice.

Best Answer

The String.startsWith method is case sensitive.

However there is a String.startsWithIgnoreCase method which as the name notes is case insensitive.