Returns the next random string of length LENGTH.
(int length)
| 18 | |
| 19 | /** Returns the next random string of length LENGTH. */ |
| 20 | public static String randomString(int length) { |
| 21 | char[] someChars = new char[length]; |
| 22 | for (int i = 0; i < length; i++) { |
| 23 | someChars[i] = (char) (r.nextInt(ALPHABET_SIZE) + 'a'); |
| 24 | } |
| 25 | return new String(someChars); |
| 26 | } |
| 27 | |
| 28 | /** Returns true if string S consists of characters between |
| 29 | * 'a' and 'z' only. No spaces, numbers, upper-case, or any other |