So I started learning java several days ago and got a question. For the next 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 implicitly assigning a integer to a string is not allowed, why the expression above works? Anyone can give a detailed explanation? I'm also wondering when can we use this kind of implicit thing and when we cannot.