public boolean equals(Object anObject) {
if (this == anObject) {
return true;
}
if (anObject instanceof String) {
String anotherString = (String)anObject;
int n = value.length;
if (n == anotherString.value.length) {//这个Value在API中找不到,而且自己输入编译器会报错。这是什么情况?
char v1[] = value;
char v2[] = anotherString.value;
int i = 0;
while (n-- != 0) {
if (v1[i] != v2[i])
return false;
i++;
}
return true;
}
}
return false;
}
------解决思路----------------------
/** The value is used for character storage. */
private final char value[];
value是String对象的一个私有成员变量