(int length)
| 4 | |
| 5 | public class Random_Str { |
| 6 | public static String generateRandomStr(int length) { |
| 7 | String base = "abcdefghijklmnopqrstuvwxyz0123456789"; |
| 8 | Random random = new Random(); |
| 9 | StringBuilder sb = new StringBuilder(); |
| 10 | for (int i = 0; i < length; i++) { |
| 11 | int number = random.nextInt(base.length()); |
| 12 | sb.append(base.charAt(number)); |
| 13 | } |
| 14 | return sb.toString(); |
| 15 | } |
| 16 | } |