Given an input String, what is the most efficient way to make just the first character lower case?
I can think of a number of ways to do this. For example, using charAt
and subString
:
String string= "SomeInputString";
string = Character.toLowerCase(
string.charAt(0)) + (string.length() > 1 ? string.substring(1) : "");
Or using a char
array:
String string= "SomeInputString";
char c[] = string.toCharArray();
c[0] = Character.toLowerCase(c[0]);
string = new String( c );
I am about to run some tests for the above examples, but I am sure there are many other ways to achieve this effect. What do you recommend?