commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stephen Colebourne" <>
Subject [Lang] Add hashcode generating methods to Lang
Date Sun, 30 Jun 2002 23:02:44 GMT
Proposal from previous thread:
> > 2) add hashCode building methods to Objects, or its own class based on
> > hashCode practice

What I have in mind is as follows:
public class Foo {
 private String a;
 private long b;
 private boolean c;

public int hashCode() {
  int total = 17;  // odd magic number
  total =, a);
  total =, b);
  total =, c);
  return total;

The HashCodeUtils class would contain one method per primitive type, and one
for objects. the implementation would add to the passed in total as per the
rules in Joshua Blochs Effective Java book.

I suggest a separate class for this just for clarity, but the methods could
sit on Objects.


To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message