Created
October 6, 2016 16:35
-
-
Save Ansh1234/dcf482f2e9cddea1a3017b12acef687d to your computer and use it in GitHub Desktop.
This file contains 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 RandomClass{ | |
private static final String characters = "abcdefghijklmnopqrstuvwxyz0123456789"; | |
public static String getRandomString(int length) { | |
if (length < 0 || length > 10) { | |
return "Random"; | |
} | |
StringBuilder stringBuilder = new StringBuilder(); | |
Random random = new Random(); | |
for (int i = 0; i < length; i++) { | |
int index = random.nextInt(36); | |
stringBuilder.append(characters.charAt(index)); | |
} | |
Utils.putToSleep(1000); | |
return stringBuilder.toString(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment