Ryan McClain wrote:. . . Does the value at the right side evaluate as an integer and therefore overflows the maximum integer range?
Yes
It does not automatically convert to a long type (since I am assigning it to a long)? . . .
No. All arithmetic, as you have been told, is done in ints until you have a long as one of the operands. The assignment operator has a lower precedence than all the other operators so you are not assigning the result to a long until after it has overflowed.
The solution is this:
. . .
Note that the (long) cast is applied to 365,
not to the result of the arithmetic. That has to do with precedences, too.
Better solution:-
public static final long MILLISECONDS_IN_YEAR =
365L * 24 * 60 * 60 * 1000;
Please put some spaces in your code; we have suggestions
here.