i have a problem with checking equality of two arraylists in JUnit tests. When i test equality of two lists, it only checks if their string representation is the same. It works for simple examples, like [1,2,3],[1,2,3] or when list contains objects that are string-represented with all of their properties. But when i have two lists that have same string representation but some objects have different properties how do i check their equality?
This is the example:
If i have Object of Class Human(int height, int weight, boolean alive), and toString() method is:
public static String toString() {
return this.height + "-" + this.weight;
}
And i have two lists [20-30] and [20-30] but the object in first have
boolean alive = false
and in second
boolean alive = true
how to tell the compiler that lists are not equal? Sorry for confusing explanation and thank you in advance!!! :D