Multiplication operation in Java is resulting in negative value

后端 未结 4 1852
野趣味
野趣味 2020-11-29 11:15

Why does the below calculation produce a negative value?

long interval = 0;

interval = ((60000 * 60) * 24) * 30;
4条回答
  •  死守一世寂寞
    2020-11-29 12:00

    Because the value of the equation is causing a number so big that it wraps around It will result in a Integer. Int

提交回复
热议问题