Why when i use this:
int a = 1;
methodWithParamString(a + "");
a is cast to String, bu i can't use toString() on integer?
int a = 1;
methodWithParamString(a.toString());
Doesn't this: a+""
works like: a.toString() + ""
?
Why when i use this:
int a = 1;
methodWithParamString(a + "");
a is cast to String, bu i can't use toString() on integer?
int a = 1;
methodWithParamString(a.toString());
Doesn't this: a+""
works like: a.toString() + ""
?
Because int a - is not an object, it is primitive type. So it doesn't have any methods. You should use boxing: