File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

hash codes for classes that do not implement the hashCode() method

 
Rachel Glenn
Ranch Hand
Posts: 95
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Suppose I have a class called Dog, as follows:




This class does not implement the hashCode() method.

Is it guaranteed then that all instances of Dog will produce unique hash codes (that I assume are generated by the java run time) ?
 
Matthew Brown
Bartender
Posts: 4549
8
Java Netbeans IDE Scala
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There's no guarantee they'll be unique. Thing about this: you can create more objects than there are int values, in which case you'd have to have duplicate hash codes. But there's a good chance that they will be distinct.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic