Last time, when our team reviewed my code, they pointed several problems of my code. I'm really happy to learn from them. Until now, what I do is only to make the code work. Then, I'll try to refactor it as well as I can. The lack of comprehensive knowledge in Java blocks me to write effective and clean code. After that, I start learning Java again to know more effective way.
I started learning from http://www.javapractices.com. This is a good website to learn Java.
Today I take a look at compareTo, equals and hashcode. Because one of our project need to use Object as key, I only override compareTo, I didn't know we still need to override equals. And when we override equals, we need to override hashcode. After I take a look at those three concepts, I know clearly about it.
Here is the references of them:
CompareTo: http://www.javapractices.com/topic/TopicAction.do;jsessionid=A5F619613C75E732660049F98FB09B13?Id=10
equals: http://www.javapractices.com/topic/TopicAction.do;jsessionid=A5F619613C75E732660049F98FB09B13?Id=17
hashcode: http://www.javapractices.com/topic/TopicAction.do;jsessionid=A5F619613C75E732660049F98FB09B13?Id=28
Java代码重构与方法重写
作者分享了团队代码审查后的收获,意识到仅使代码运行还不够,还需关注代码质量和效率。决定重新学习Java以提高技能,并研究了compareTo、equals及hashCode方法的正确使用方式。
1106

被折叠的 条评论
为什么被折叠?



