如果我使用compareTo
和BigInteger
,我该如何从结果中选择要调用的函数? (-1 = funcA,+1 = funcB,0 =没有函数)。基于compareTo的调用方法?
特别是:这是怎么回事?
doCompare() {
BigInteger x = new BigInteger(5);
BigInteger y = new BigInteger(10);
//syntax error token "<", invalid assignment operator
x.compareTo(y) < 0 ? funcA() : funcB();
}
void funcA();
void funcB();
为什么不将结果转换为临时值并且如果/ else? – kosa
因为这只是一个抽象我的问题的例子... – membersound