• 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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Dan's Wrapper Class Doubt

 
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Friends,
The answer for this question is "c",but I am wondering why not "a,c".The two Integer objects i1,i2 are not equal and they might have equal or unequal hashcodes.So(h1 == h2),could return "true" or "false",you never know.Please correct me ..and lemme know where i am going wrong.

Thanks in Advance.
 
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

The two Integer objects i1,i2 are not equal



Are you saying i1.equals(i2) returns false? I suggest you try it.
 
Jas Oberai
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Barry,
After going thru your reply,i understood where i was goin wrong.By saying not equal,i meant that i1,i2 are refering to two different objects on the heap,but i knew i1.equals(i2) is true as the contents were the same.And I was thinking that the hashcode is calculated depending upon the reference i.e "==".Actually,that was my stupidity..sorry!!!
 
I was born with webbed fish toes. This tiny ad is my only friend:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic