java - How to generate a hashcode from object with two list containing the same type of objects -


let's have class (the equal method exists):

public class someclassa {     private int a;     private int b;          @override  public int hashcode() {     final int prime = 31;     int result = 1;     result = prime * result + a;     result = prime * result + b;     return result;  } } 

and class:

public class someclassb {   list<someclassa> firstlist;   list<someclassa> secondlist; 

how construct hashcode 2 objects seen equals if have same objects in firstlist , same objects in secondlist.

//hank

 public int hashcode() {     final int prime = 31;     int result = 1;     result = prime * result + firstlist.hashcode();     result = prime * result + secondlist.hashcode();     return result;  } 

Comments

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

javascript - oscilloscope of speaker input stops rendering after a few seconds -