In Java, the class String implements Comparable, which means there's a total ordering on the String objects. This ordering is referred to as the class's natural ordering, and the class's compareTo
method is referred to as its natural comparison method. The set of String objects is also countable in the mathematical sense.
I need a function that takes a String and returns the next one according to String's natural ordering.
For the mathematically inclined,
function(X) = Y, where Y is such that: 1) X < Y
2) for all Z, if X < Z, then Y <= Z.
Can you think of a function that does this for Strings? (Those matching ^[A-Za-z0-9]+$
. I don't care, but you can avoid the control characters or anything that might cause headaches with encodings, is illegal in XML, has line breaks, or similar "problematic" characters.)