So, I started learning java a few days ago and got a question. For the following expression:
String foo=123;
is not allowed. However, in System.out.printIn() we can use something like:
int x=5; System.out.println(x);
Since implicit assignment of an integer to a string is not allowed, why does the expression above work? Can anyone give a detailed explanation? I also wonder when we can use this implicit thing, and when we cannot.
Onezero
source share