标题:java.lang.String里的equals()方法的源码,我看不懂,求解释!!
取消只看楼主
寂寞编程孤独
Rank: 1
等 级:新手上路
帖 子:20
专家分:6
注 册:2010-10-26
结帖率:57.14%
已结贴  问题点数:5 回复次数:0 
java.lang.String里的equals()方法的源码,我看不懂,求解释!!
public boolean equals(Object anObject) {
    if (this == anObject) {
        return true;
    }
    if (anObject instanceof String) {
        String anotherString = (String)anObject;
        int n = count;
        if (n == anotherString.count) {
        char v1[] = value;
        char v2[] = anotherString.value;
        int i = offset;
        int j = anotherString.offset;
        while (n-- != 0) {
            if (v1[i++] != v2[j++])
            return false;
        }
        return true;
        }
    }
    return false;
    }
上面是源码!!
int n = count;
        if (n == anotherString.count)
count表示的是什么?
最好是从头到尾解释说明一下!!
搜索更多相关主题的帖子: false 
2011-03-03 11:02



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-333106-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.810830 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved