lexicographic

String Comparison in Java

☆樱花仙子☆ 提交于 2019-11-26 03:35:38
问题 What does \"compare two strings lexicographically\" mean? 回答1: 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 can be interpreted as follows: returns < 0 then the String calling the method is lexicographically