Like this:
BigInteger val = new BigInteger("1254789363254125");
public boolean odd(BigInteger val) {
if(!val.mod(new BigInteger("2")).equals(BigInteger.ZERO))
return true;
return false;
}
Or as user Duncan suggested in a comment, we can take out the if statement altogether like so:
BigInteger val = new BigInteger("1254789363254125");
public boolean odd(BigInteger val) {
return !val.mod(new BigInteger("2")).equals(BigInteger.ZERO));
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…