Helper function for nextString. Increments the Pth position of X by one, wrapping around to 'a' if p == 'z'. If wraparound occurs, then we need to carry the one, and we increment position P - 1. Will fail for a character array containing only zs.
(char [] x, int p)
| 55 | * Will fail for a character array containing only zs. |
| 56 | */ |
| 57 | private static void incrementCharArray(char [] x, int p) { |
| 58 | if (x[p] != 'z') { |
| 59 | x[p] += 1; |
| 60 | } else { |
| 61 | x[p] = 'a'; |
| 62 | incrementCharArray(x, p - 1); |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | /** Returns a string of all 'a' of length LEN. */ |
| 67 | private static String allAs(int len) { |