• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

equals() and hascode() doubt

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Hi all!
I am new to this.


may I know why if or else of equals method is not printing?
correct me

Thanks
roberto

 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

may I know why if or else of equals method is not printing?
correct me



Take a look at what the type of the "sc" reference is....



The "sc" reference is a superclass type. Does the equals() method of the superclass type print anything?

Henry
 
Ranch Hand
Posts: 1274
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Howdy!

roberto nasel posted Today 08:19


Hi all!
I am new to this.




I see, your first posting.
Welcome to the Ranch!!



You have overridden the equals only in the sub class HasHash, but you are invoking the method in the super class:
HasHash ha1 = new HasHash(8);
superclass sc = new superclass(8);
sc.equals(ha1);

sc doesn't have an overridden equals method. Therefore no printing.



Yours,
Bu.
 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by roberto nasel: you declared int hashCode() return x;
that's it's not printing correct
[QB][/QB]

 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic