Converts the entire string into uppercase and lowercase letters, and returns the string in uppercase and lowercase letters.
Recently I used the uppercase Character function. The general idea is to use charAt (0) combined with Character's toUpperCase Method for conversion, and finally combine it into a string.
A few days ago, I saw a great god's code and thought it was highly efficient. If you are interested, please take a look.
The Code is as follows:
/*** Capitalized conversion * @ param str source String. Chinese characters * @ return */public static String firstCharUpper (String str) {if (str! = Null & Character. isLowerCase (str. charAt (0) {// determine whether it is in upper or lower case based on your needs. Modify char [] charArray = str. toCharArray (); if (charArray! = Null) {charArray [0]-= 32; // convert lowercase to uppercase. If it is lowercase to lowercase, It is + = 32. You need to judge return String above. valueOf (charArray) ;}} return str ;}
The following is a string that is similar to the upper-case string.
/*** Capitalized String * @ param str * @ return */public static String strUpperCase (String str) {if (str! = Null) {char [] charArray = str. toCharArray (); for (int I = 0; I <str. length (); I ++) {if (Character. isLowerCase (str. charAt (I) charArray [I]-= 32;} return String. valueOf (charArray);} return str;}/*** String lowercase * @ param str * @ return */public static String strLowerCase (String str) {if (str! = Null) {char [] charArray = str. toCharArray (); for (int I = 0; I <str. length (); I ++) {if (Character. isUpperCase (str. charAt (I) charArray [I] + = 32;} return String. valueOf (charArray);} return str ;}
For more information, see.
@ Ink