由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Java版 - Top Ten Errors Java Programmers Make(7)
相关主题
Top Ten Errors Java Programmers Make(6)Object比较
Top Ten Errors Java Programmers Make(10)Comparator Accessor method for SortedSet
Top Ten Errors Java Programmers Make(8)泛型问题
Top Ten Errors Java Programmers Make(5)Help with Tomcat for Eclipse v1.03
Top Ten Errors Java Programmers Make(4)Tomcat JSP syntax error
Top Ten Errors Java Programmers Make(3)developer, programmer, software engieer有什么区别
Top Ten Errors Java Programmers Make(2)Re: 谁有Java或Oracle的毒招 ?
Top Ten Errors Java Programmers Make(1)Re: weird problem with hashtable--CONCLUSION
相关话题的讨论汇总
话题: def话题: two话题: string话题: ten话题: make
进入Java版参与讨论
1 (共1页)
b*g
发帖数: 644
1
7. Comparing two objects ( == instead of .equals)
When we use the == operator, we are actually comparing two object
references, to see if they point to the same object. We cannot compare,
for example, two strings for equality, using the == operator. We must
instead use the .equals method, which is a method inherited by all
classes from java.lang.Object.
Here's the correct way to compare two strings.
String abc = "abc"; String def = "def";
// Bad way
if ( (abc + def) == "abcdef" )
{
......
}
1 (共1页)
进入Java版参与讨论
相关主题
Re: weird problem with hashtable--CONCLUSIONTop Ten Errors Java Programmers Make(4)
how to normalize an image?Top Ten Errors Java Programmers Make(3)
what this line of code mean?Top Ten Errors Java Programmers Make(2)
Help Cookie getMaxAge() always return -1Top Ten Errors Java Programmers Make(1)
Top Ten Errors Java Programmers Make(6)Object比较
Top Ten Errors Java Programmers Make(10)Comparator Accessor method for SortedSet
Top Ten Errors Java Programmers Make(8)泛型问题
Top Ten Errors Java Programmers Make(5)Help with Tomcat for Eclipse v1.03
相关话题的讨论汇总
话题: def话题: two话题: string话题: ten话题: make