So GREAT The new version of Effective Java(2nd edition) is! (Better than Effective c# 1 million times)
I’m reading this book and finding that lots of the skill can be used by other language programmers, especially c#’s.
This series of notes will cover the the things for both java and c#.
Wish you like it.
Methods Common to All Objects
- Item 8: Obey the general contract when overriding equals
It’s not a new problem.
I don’t wanna repeat the detail of how to write your new equals method.
I just wanna notice the c# programmer: when you override the equals (and the == and != operators), you should implement the IEquatable interface as well.
- Item 9: Always override hashCode when you override equals
Nothing to say.
- Item 10: Always override toString
Do this. You will feel good when you debug your code.
- Item 11: Override clone judiciously
Nothing to say.
- Item 12: Consider implementing Comparable
Nothing to say.
- iron9light’s item: Read the CLR via c#
The methods in the Object class look so identical in Java and c#. This is why someone said that the c# is a copy of Java.
All the problem above are discussed in CLR via c# very clearly. If you are a c# programmer. Read it. It will tell you something for c# only like Equals for struct etc.
Tags: c#, Java, Joshua bloch, Effective Java