Java string, which needs to be rewritten with a first letter capitalization

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.