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;
}
Map 中的Object 如果为Integer 就false ,如果为String 就为true,说明两个对象的类型不一至,可以map.get("bbid").toString();确保bbid存在即可
确认一下bbid或者map.get("bbid")获取的值后面没有空格。
System.out.println(map.get("bbid")+",");
System.out.println(bbid+",");看看后面是不是有空格
equals()方法的本意为确定两个对象的引用是否相同
如果比较两个值是否一样,使用=判断吧
map.get(bbid)不是string型的,当然false了
map取出来的是object类型
map.get("bbid")是个Object,请确保和bbid是一种类型