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