How does "return newBit == false ? 0 : 1;" works in java programming?
- EddieJLv 75 months agoFavorite Answer
It's a shorter way of saying:
if (newBit == false) return 0; else return 1;
However, there is a shorter way
return newBit ? 1 : 0;
Assuming newBit is a boolean, you don't have to compare it to true or false.
https://www.tutorialspoint.c/ o m/Java-Ternary-Operator-Examples