MCPcopy Create free account
hub / github.com/Berkeley-CS61B/skeleton-sp23 / randomString

Method randomString

lab07/tests/StringUtils.java:20–26  ·  view source on GitHub ↗

Returns the next random string of length LENGTH.

(int length)

Source from the content-addressed store, hash-verified

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

Callers 1

insertRandomMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected