Posted By

intoxicadocoder on 04/26/11


Tagged

java


Versions (?)

El metodo hashCode


 / Published in: Java
 

metodo para generar hashcodes

  1. int hashCode = 0;
  2.  
  3. @Override
  4. public int hashCode() {
  5. if (this.hashCode == 0) {
  6. return genericHash(this.id_otro_responsable,getId_persona());
  7. }
  8. return id_otro_responsable;
  9. }
  10.  
  11. public static int genericHash(int... fieldHashes) {
  12. int result = 17;
  13. for (int hash : fieldHashes) {
  14. result = 37 * result + hash;
  15. }
  16. return result;
  17. }

Report this snippet  

You need to login to post a comment.