Skip to content
Advertisement

Tag: string-comparison

String Comparison in Java

What does “compare two strings lexicographically” mean? Answer Leading from answers from @Bozho and @aioobe, lexicographic comparisons are similar to the ordering that one might find in a dictionary. The Java String class provides the .compareTo () method in order to lexicographically compare Strings. It is used like this “apple”.compareTo (“banana”). The return of this method is an int which

Advertisement