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
Post a Comment