You wouldn't be able to compile
doSomethingWithLong((long) 222222222222222222);
// The literal 222222222222222222 of type int is out of range
Because 222222222222222222
doesn't fit in int
.
You can read about the primitive data types in this official Java tutorial.
The int data type is a 32-bit signed two's complement integer. It has
a minimum value of -2,147,483,648 and a maximum value of 2,147,483,647
(inclusive).
The long data type is a 64-bit signed two's complement integer. It has
a minimum value of -9,223,372,036,854,775,808 and a maximum value of
9,223,372,036,854,775,807 (inclusive).
Let's assume that the code still compiles with the literal value that is used.
They are equivalent, see Rohit's byte code answer.