import java.util.Random;
public class Test {
public static void main(final String[] args) {
final String romaji = "abcdefghijklmnopqrstuvwxyz";
final String number = "0123456789";
final String generator = romaji + romaji.toUpperCase() +number;
System.out.println(getStr(generator, 10));
System.out.println(getStr(generator, 10));
System.out.println(getStr(generator, 10));
}
private static String getStr(final String input, final int length) {
final Random random = new Random();
final int num = input.length();
final StringBuilder sb = new StringBuilder();
final char[] chars = input.toCharArray();
for (int i = 0; i < 10; i++) {
sb.append(chars[random.nextInt(num)]);
}
return sb.toString();
}
}
More than 5 years have passed since last update.
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme