Re: Re: transactions - equals and hashcode method

Leo Mekenkamp <[email protected]>
Newsgroups gmane.comp.java.ozone.user
Message-ID <1078414175.31753.12.camel@mars>
On Thu, 2004-03-04 at 16:07, Sunil Goyal wrote:
> Hello all,
> 
> It looks the bug I was trying to find is because of the equals method.
> 
> I am using something like this..
> 
> class AImpl extends OzoneObject impelements A{
>     String OID;  //
> 
>     public boolean equals(Object obj) {
>          if (obj != null) {
>          	if (OID.equals(((A)obj).getOID()) )
>              	return true;
> 		}
>          return false;
>      }
> 
>      public int hashCode() {
> 		return OID.hashCode();
>      }
> }
> 
> Looks like this is giving me troubles and resulted in stack
> overflow troubles later.

Are you sure you have no kind of recursion going on? 99 out of 100 stack
overflows I get are recursion related.

> Is there some problem using the above approach for equals() and
> hashcode() methods?

No.

Cheers,
Leo




-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.