BigInteger
s are Object
s so you cannot compare their contents with relational operators such as >
, and ==
won't compare contents; it will compare object references.
However, BigInteger
does implement Comparable<BigInteger>
, so call compareTo
instead.
- For equality, use
left.compareTo(right) == 0
. - For less than, use
left.compareTo(right) < 0
. - For greater than, use
left.compareTo(right) > 0
.