Returns the string that comes right after S in alphabetical order. For example, if s is 'potato', this method will return 'potatp'. If the last character is a z, then we add to the next position, and so on.
(String s)
| 39 | * on. |
| 40 | */ |
| 41 | public static String nextString(String s) { |
| 42 | /* Handle all zs as a special case to keep helper method simple. */ |
| 43 | if (isAllzs(s)) { |
| 44 | return allAs(s.length() + 1); |
| 45 | } |
| 46 | char[] charVersion = s.toCharArray(); |
| 47 | incrementCharArray(charVersion, charVersion.length - 1); |
| 48 | return new String(charVersion); |
| 49 | } |
| 50 | |
| 51 | /** Helper function for nextString. Increments the Pth position of X |
| 52 | * by one, wrapping around to 'a' if p == 'z'. If wraparound occurs, |
no test coverage detected