Java string, the need to write the first letter to rewrite, the internet is basically the same way of thinking, is to intercept the first letter, converted to uppercase and then string back, similar to the following code
Capitalize first letter
public static string Capturename (string name) {
Name = name.substring (0, 1). toUpperCase () + name.substring (1);
return name;
}
Converts the string name to uppercase. But this efficiency is not high, I have seen a bull man's writing method of the core code, is this
Capitalize first letter
public static string Capturename (string name) {
Name = name.substring (0, 1). toUpperCase () + name.substring (1);
return name;
Char[] Cs=name.tochararray ();
cs[0]-=32;
Return string.valueof (CS);
}
The heart is heartfelt admiration, that is, the letter ASCII encoding forward, but this article can not be found on the internet, so here to record a bit, for review purposes.
Java string, which needs to be rewritten with a first letter capitalization