Java Generate Verification Code

Source: Internet
Author: User

                Random y=new random (); int S=y.nextint (37); String a= "S7Q8R5S2B1G2D3S6A9F5C1V2F5H6J8G9P6H9F8C1"; System.out.println (a.substring (S, s+4));

Basic idea: First insert a string of numbers and letters;

Then the random number is generated by random numbers.

The resulting random number is then used as an index to intercept the next four bits of the number.

Output Result:

 

The second method of

Basic ideas

1. Define a string[]zimu={"a", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "s", "T", "U", "V", "W "," X "," Y "," Z "};

2. Generate random number as index

3. Generate a number within 10

4, output.

String[]zimu={"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "s", "T", "U", "V", "w", "X", "Y", "Z"}; Random suoyin=new random (); Random shu=new random (); System.out.println (Zimu[suoyin.nextint)]+shu.nextint (]+shu.nextint) +zimu[suoyin.nextint (10));

  

Output results

Java Generate Verification Code

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.