// Very important to edit ...
Giorgi, I know that you accepted the answer below correctly, but I found it wrong.
If you have a class like this:
class tiny { int a; public int hashCode() { return a; } }
You have already selected all possible hash codes. (If it is not clear why, say so.)
So, if you add ANY additional information to the object, if you want the information presented in hashCode, you will have a collision somewhere.
But, in this regard, you really do not want to set a hash code that is 100% unique to the object. This is really not a hashCode point!
The hashCode point should provide you with a unique identifier for the object so that you can put it in the hash bucket. This is not for identification as it is for classification. The idea is that if you have a whole bunch of objects, you probably won't have a lot of collisions, so you'll probably have pretty quick access to what you're looking for if you grouped the elements by their hashCode.
If this means that you canceled my answer as correct, everything is in order. This is really wrong for what you are looking for. I hope you understand that this hashCode explanation leads to proper use, thereby preserving the correctness. But, as Mark clearly pointed out, this does not actually solve the problem you stated.
Below is the old answer:
==================================================== ==========
A good article about it is here from Effective Java (reveals the best book βI Want to Learn to Be a Good Java Developerβ there).
http://www.linuxtopia.org/online_books/programming_books/thinking_in_java/TIJ313_029.htm
class Gjorgji { boolean a; boolean b; boolean c; int x; int y;