class foo { public void bar(int i) { ... }; public void bar(long i) { ... }; } foo.bar(10);
I would expect this code to give me some error, o
I would say if you exceed below limit
-2,147,483,648 to 2,147,483,647
control will go to long
long
Range for long
–9,223,372,036,854,775,808 to 9,223,372,036,854,775,807
Max value for int
foo.bar(-2147483648);
or
foo.bar(2147483648);
Long will get control if we exceed the value by 2147483648
Long