Comment on Java Puzzle: Square RootparentComments−raylu13yYou can override the .equals() for your subtype but look at the check: if (n.divide(root).equals(root)) { It never calls root.equals(). It calls .equals() on the result of the .divide(), which is a standard java.math.BigInteger.
Comments
You can override the .equals() for your subtype but look at the check:
It never calls root.equals(). It calls .equals() on the result of the .divide(), which is a standard java.math.BigInteger.