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)