Use ASCII code to generate a string of a specified rule

Source: Internet
Author: User

 

 

/*** The last two generation rules of the sending terminal number can generate (36*36-1) 1295 numbers * 01... 09 0a... 0z * 10... 19 1A... 1z *............... * A0... a9 aa... AZ *............... * z0... z9 Za... ZZ */Public String generatenumber (string number) {string ret = number. substring (0, number. length ()-2); // obtain the first half of the number = number. substring (number. length ()-2); // take the last two digits // take the first character char character = number. charat (0); char CH2 = number. charat (1); // generate the second string if (number. equals ("ZZ") {// reaches the upper limit ZZ. return NULL is not generated using the generation rule.} If (CH2 <'Z ') {// The next letter of 9 is a if (CH2 = '9') {CH2 = 'a';} else {CH2 + = 1 ;} ret = RET + "" + cursor + CH2;} else {// Add 1 to the first character; 0 to the second if (then = '9 ') {response = 'a';} else {response + = 1;} ret = RET + "" + response + 0;} return ret ;}
public static void main(String[] args){        String[] arr={"01","09","0A","0Y","0Z","90","99","9B","9Z","A0","AZ","Z0","ZY","ZZ"};        for(String arr1:arr){            System.out.println("--->:"+test(arr1));        }            }

 

Use ASCII code to generate a string of a specified rule

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.