The limit of int
is from -2147483648 to 2147483647.
If I input
int i = 2147483648;
then Eclipse will prompt a red underline under "2147483648".
But if I do this:
int i = 1024 * 1024 * 1024 * 1024;
it will compile fine.
public class Test {
public static void main(String[] args) {
int i = 2147483648; // error
int j = 1024 * 1024 * 1024 * 1024; // no error
}
}
Maybe it's a basic question in Java, but I have no idea why the second variant produces no error.
See Question&Answers more detail:os