It is well known that an equals()object's method , if not overridden, is a “shallow comparison" equivalent to using the "==" operator. (See, for example, https://docs.oracle.com/javase/tutorial/java/IandI/objectclass.html .)
Question: Why does Java not provide a equals()default “deep comparison” method ? That is, one that will recursively call equals()for each of its instance variables. In the end, recursion will reach primitive types and stop. Are there any flaws if this deep comparison value was the default?
source
share