Skip to content

Instantly share code, notes, and snippets.

@Ansh1234
Created October 6, 2016 16:35
Show Gist options
  • Save Ansh1234/dcf482f2e9cddea1a3017b12acef687d to your computer and use it in GitHub Desktop.
Save Ansh1234/dcf482f2e9cddea1a3017b12acef687d to your computer and use it in GitHub Desktop.
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