Why is the product of the 3 coming out to be 0?
Your multiplication is being done in int
arithmetic, and it's overflowing, with a result of 0. You're basically doing 224 * 224, i.e. 248 - and the bottom 32 bits of that results are all 0. The fact that you assign the result of the operation to a long
doesn't change the type used to perform the operation.
To perform the arithmetic using 64-bit integer arithmetic, just change an operand to be long
:
private static final long RESULT = (long) FIRST * SECOND * THIRD;