String-demand converts the first letter of a string to uppercase and the remainder to lowercase (only the English-uppercase alphabetic characters are considered)

Source: Internet
Author: User

Package Cn.lianxi; Public classDaxiao { Public Static voidMain (string[] args) {/*The demand turns the first letter of a string into uppercase and the rest to lowercase (only English-uppercase alphabetic characters are considered) * Analysis: * 1. Get the first character * 2. Gets the characters except the first character         * 3. Turn the first character into uppercase * 4. Turn the first character into uppercase * 5. Convert characters other than the first character to lowercase * 6. String concatenation * */String str="HelloWORLD"; String str2= Str.substring (0,1); String STR3= Str.substring (1); String STR4=str2.touppercase (); String STR5=str3.tolowercase (); String STR6=Str4.concat (STR5); System. out. println ("The result is:"+STR6); //Optimized CodeSystem. out. println (Str.substring (0,1). toUpperCase (). Concat (Str.substring (1). toLowerCase ())); }}

String-demand converts the first letter of a string to uppercase and the remainder to lowercase (only the English-uppercase alphabetic characters are considered)

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.