This week's book giveaway is in the OCMJEA forum. We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line! See this thread for details.
I have written the following code which puts in three key value pairs in a map and then fetches one of them based on the key.
I am getting a null value while doing the get operation why??
I know that I have overridden the equals and hashcode functions of only the key class and not the value class. But it should still work because on doing the get operation only key class is called is that no correct?
utsav gupta wrote:Can you please tell something more about @Override . I have never come across this before.
From the doc,
Indicates that a method declaration is intended to override a method declaration in a supertype. If a method is annotated with this annotation type compilers are required to generate an error message unless at least one of the following conditions hold:
* The method does override or implement a method declared in a supertype.
* The method has a signature that is override-equivalent to that of any public method declared in Object.
Thus apart from the advantage that Rob already mentioned, the other benefit you get while using this annotation is that if the parent class modified, the compiler will make sure that the child classes have been updated accordingly.