Created
May 21, 2016 15:46
-
-
Save FrankCharlz/5932215abdf79262fcaa736e21910113 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class M { | |
| private String generateRandomString(int length) { | |
| Random rn = new Random(); | |
| char small = 'a'; | |
| char capital = 'A'; | |
| StringBuilder sb = new StringBuilder(length); | |
| for (int i=0; i<length; i++){ | |
| if(rn.nextBoolean()) | |
| sb.append((char)(small + rn.nextInt(26))); | |
| else | |
| sb.append((char)(capital + rn.nextInt(26))); | |
| } | |
| return sb.toString(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment