1、注意不能用==运算符测试字串相等性,它只能判断出两个字串是否存在相同的内存位置。
2、判断两个字串相等是用 S equals(T)和equalsIgnoreCase,后者不判断大小写
如:“Hello”.equalsIgnorecase("hello")他的返回值是true;
2、判断两个字串相等是用 S equals(T)和equalsIgnoreCase,后者不判断大小写
如:“Hello”.equalsIgnorecase("hello")他的返回值是true;
调试欢乐多
http://www.12Yeah.com/default2.htm?user=abcd
应该就可以了
!
这里应该用"equals".
class Employee{
...
public boolean equals(Object otherObject){
if(this == otherObject) return true;
if(otherObject == null) return false;
if(getClass() != otherObject.getClass()) return false;
(类名) other = (类名)otherObject;
return 对象类型的字段.equals(other.对象类型的字段)
&& 字段2 == other.字段2
[&& ...] ;
}
}