Exforsys

Free Training

Difference between hashcode() and equals()...

This is a discussion on Difference between hashcode() and equals()... within the Java forums, part of the Programming Talk category; I have tried so many times to find the difference...but not getting a satisfactory explanation.... can anybody explain with a ...

Go Back   Exforsys > Programming Talk > Java

Exforsys.com

  #1 (permalink)  
Old 09-26-2007, 05:07 AM
Junior Member
 
Join Date: Sep 2007
Posts: 3
singhsn is on a distinguished road
Difference between hashcode() and equals()...

I have tried so many times to find the difference...but not getting a satisfactory explanation.... can anybody explain with a good example??
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 03-07-2008, 04:47 AM
Junior Member
 
Join Date: Mar 2008
Location: bangalore
Posts: 9
sampra is on a distinguished road
hashcode is an integer number which is provide to each object by jvm note that this is not address of object but for convencing internally they use

equals() is used to compare the objects it returns boolean value
if any doubt then pls ask
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 01-26-2009, 05:06 PM
Junior Member
 
Join Date: Jan 2009
Posts: 2
Bijay29 is on a distinguished road
Compares values for equality. Because this method is defined in the Object class, from which all other classes are derived, it's automatically defined for every class. However, it doesn't perform an intelligent comparison for most classes unless the class overrides it. It has been defined in a meaningful way for most Java core classes. If it's not defined for a (user) class, it behaves the same as ==.
It turns out that defining equals() isn't trivial; in fact it's moderately hard to get it right, especially in the case of subclasses.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 11:08 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0
Copyright 2004 - 2009 Exforsys Inc. All rights reserved.