I thought long and Long class are more or less same thing. I saw this link
When I displayed Long.MAX_VALUE
it displayed 9223372036854775807
.
But when I was doing multiplication of 1000000*1000000
which is 10^12
; it gave overflow.
I was using long data type to store value...and while debugging it had value -727379968
after multiplication
Where am I making mistake or I am totally dumb?
Update: This was my code, and I got my mistake as specified in answer.
for (;;)
ppltn[i] = Integer.parseInt(tk.nextToken());
for (int i = 0; i < noc; i++) //sum is of long type
sum = sum + min * ppltn[i]; //min and ppltn are of integer type