Converts all lowercase letters in a string to uppercase letters, and the rest remain unchanged. The stirng. touppercase () method cannot be used.

Source: Internet
Author: User

/** <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

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.