Java basic question
I really don't understand, why the statement System.out.println() is correct. First, the out variable returns PrintStream object, which has println method, and this is in java.io package. So, how complier finds it? This is making me bemuse .
Thanks in advance for any valuable suggestion.
out doesn't "return" a PrintStream object, it is a PrintStream object.
java.io.PrintStream is used only in the class java.lang.System, which has already been complied. You only need imports when you explicitly use a class name.
You can actually import java.lang.System.*; and then just type out.println()
(pointless fact but a little neat I guess)