从compareTo
的Javadoc:
如果在这两个字符串不同的指标,结果是 最低这类指数
在两个字符的之间的区别
完整的Javadoc:
/**
* Compares this string to the given string.
*
* <p>The strings are compared one {@code char} at a time.
* In the discussion of the return value below, note that {@code char} does not
* mean code point, though this should only be visible for surrogate pairs.
*
* <p>If there is an index at which the two strings differ, the result is
* the difference between the two {@code char}s at the lowest such index.
* If not, but the lengths of the strings differ, the result is the difference
* between the two strings' lengths.
* If the strings are the same length and every {@code char} is the same, the result is 0.
*
* @throws NullPointerException
* if {@code string} is {@code null}.
*/
public native int compareTo(String string);
而且从在线文档(以上链接):
结果是负整数,如果此String对象 字典顺序优先于参数字符串
把大量的'?'在你的问题中并没有帮助你更快得到答案。一个写得很好的解释性问题效果最好。我尽可能地为你整理了它。 –