If I use compareTo an a BigInteger, how can I choose from the outcome which function to call? (-1 = funcA, +1 = funcB, 0 = no function).
Especially: what’s wrong with this?
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();
First of all, you are using
BigInteger()constructor incorrectly, it takesStringnotintorlong. And your functions must havebooleanreturn type, otherwise you cannot use them in ternary operation.