How can System.out.printIn() accept integers?

java

Solution

There are so many overloaded methods of the PrintStream `System.out`:

println(boolean x)
println(char x)
println(int x)
println(long x)
println(float x)
println(double x)
println(char x[])
println(String x)
println(Object x)

Problem

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.

Original source