public final class Lexicographic { // Return "true" if the string 'x' is lexicographically less than 'y'. static boolean lexicographic (final String x, final String y) { // No string is less than the empty string. if (y.length()==0) return false; // The empty string is less than all others (except the empty string). else if (x.length()==0) return true; else if (x.charAt(0) < y.charAt(0)) return true; else if (x.charAt(0) > y.charAt(0)) return false; else return lexicographic (x.substring(1), y.substring(1)); } }