Closed veyndan closed 8 years ago
You are correct.
Originally, I used null to check if any input had been received. In setOperator, it shouldn't calculate the operation if no input had been received, but change the operator instead. But what if the user inputs 0? Primitives can't be null. And 0 is valid input. So I used Integer.
There was only one state where mInput was null, and that was immediately after setting the operator. But that isn't used any more, because I seem to have added mInput == 0 to the if clause at line 279. So the null is indeed useless.
The use of
null
onmInput
is unnecessary as conditional statements checked for bothmInput
beingnull
or0
. Also whenmInput
is found to benull
, it is commonly set to0
anyway. Using the primitive instead of the primitives wrapper class improves readability and reduces the potential for bugs, due to the inability of primitives to be set tonull
.