You are calling
A.test()
passing the integer
i
. That is not a default type but defined by your code:
int i = sc.nextInt();
[EDIT]
Quote:
Sir I modified the code to pass 5 instead of int i.. I am getting Integer
5 is a numerical integer literal.
Yes, when there is no type hint in the literal, it is an
int
.
If it has an 'L' postfix, it is a
long
:
a.test(5L);
If the literal contains a period or an exponent, it is a
double
.
If it has an 'F' postfix, it is a
float
.
If you want to treat it as different type you can also use casting:
a.test((short)5);
[/EDIT]