Link to home
Start Free TrialLog in
Avatar of Squadless
Squadless

asked on

What is the size of INT in java?

If i have an int counter that counts the number of rows retrieved from an SQL query... would it be ok if the counter is an "int" if the maximum number of rows is 500,000?
What is the size of 'int' in java?
ASKER CERTIFIED SOLUTION
Avatar of CPColin
CPColin
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of CEHJ
Integer.MAX_VALUE  ==  2,147,483,647
yes an int would be fine for that purpose :)

Avatar of b0rg2
b0rg2

Yes, 'int' variables are represented on 4 bytes and should be suited for counting up more than 500,000 rows. The "int" type allows values from -2147483648 to 2147483647, inclusive.

Alternatively the "long" type is stored in 8 bytes and allows values from -9223372036854775808 to 9223372036854775807, inclusive.