【发布时间】:2014-05-19 05:28:09
【问题描述】:
在Java中,我们知道如果要比较两个引用对象,我们通常需要使用equals,但是在这里我对以下输出感到很困惑:
System.out.println(new BigInteger("0") == BigInteger.ZERO); // false
System.out.println(new BigInteger("0").mod(BigInteger.ONE) == BigInteger.ZERO); // true
为什么第二个说法是正确的?
【问题讨论】:
-
==是邪恶的,有时会诱使您相信它有效。只是不要注意它的输出。
标签: java biginteger modular