/** <Br/> * converts all lowercase letters in the string into uppercase letters, and the rest remain unchanged. stirng cannot be used. touppercase () method <br/> * @ author Alen <br/> */<br/> public class Change {</P> <p> Public static string changestr (string Str) {<br/> Str. touppercase (); <br/> char [] CH = Str. tochararray (); <br/> stringbuffer sb = new stringbuffer (); <br/> int A = 'a'-'A '; // obtain the difference between uppercase and lowercase letters <br/> for (INT I = 0; I <ch. length; I ++) {<br/> If ('A' <= CH [I] & Ch [I] <= 'Z ') {<br/> CH [I] = (char) (CH [I] + a); <br/>}< br/> Sb. append (CH [I]); <br/>}</P> <p> return sb. tostring (); <br/>}< br/>/** <br/> * @ Param ARGs <br/> */<br/> Public static void main (string [] ARGs) {<br/> // todo auto-generated method stub <br/> system. out. println (changestr ("aaf23fqe"); <br/>}< br/>}
Address: http://blog.csdn.net/alen1985/archive/2010/07/07/5718689.aspx