public class String { … public int compareTo(String anotherString) { int len1 = count; int len2 = anotherString.count; //n为两个字符串长度的最小者 int n = Math.min(len1, len2); //获取字符数组 char v1[] = value; char v2[] = anotherString.value; //取偏依位置 /** The offset is the first index of the storage that is used. */ //offset 是第一个存储索引 int i = offset; int j = anotherString.offset; //假如i == j //这里可能是判定取同一内存中两个字符串的情景。。。 // A <-- <---- // B s1 // C <-- // D s2 // E // F // G <---------- // 可能这种情况 i = j if (i == j) { int k = i; int lim = n + i;