Friday, November 30, 2012

Uncategorized questions

Which two method you need to implement for key Object in HashMap?
In order to use any object as Key in HashMap, it must implements equals and hashcode method in Java. Read How HashMap works in Java for detailed explanation on how equals and hashcode method is used to put and get object from HashMap. You can also see my post 5 tips to correctly override equals in Java to learn more about equals.

What are the ways in Java for indication an error in a method?
Return value;
Throwing an exception.
Changing the object state in a parameter of the method. The method has t o be passed by reference;


No comments:

Post a Comment