File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Confused in hashcode method-- Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Confused in hashcode method--" Watch "Confused in hashcode method--" New topic

Confused in hashcode method--

khushi wad

Joined: Jul 13, 2005
Posts: 2
According to one of wiz lab example

Even the state of object does not change, it is perfectly legal that the hash code returned by it may not remain consistent from one execution of an application to another execution of an application of the same application.

as per my knowledge hash code should be always same..... completely confused have exam on monday.... highly appriciate quik responses.

newgen pras
Ranch Hand

Joined: Jun 01, 2005
Posts: 34

Yes.... the hashcode will remain same for any number of calls with in a single execution ...I hope u got confussed here only .. With that execution it will remain same ..

If that program is executed second time the hash code need not be same as what we obtained in first excution but it will remain same through out the second execution ... hope this helps ...

newgen pras
Ranch Hand

Joined: Jun 01, 2005
Posts: 34
Hi find the Example code for this ...

See the hashcode value i got may be different from what u get ..but the if condition will always remain true..

I agree. Here's the link:
subject: Confused in hashcode method--
It's not a secret anymore!