So I ask myself why I don't have to import java.io.PrintStream
to use System.out
. I know that java.lang
is imported by default by the compiler. Allright.
Because System
is a class of java.lang
I can use the field System.out
. But this field has the type java.io.PrintStream
and this class is not imported by default (it's in the java.io package), so why can i access System.out.print()
for instance without importing java.io.PrintStream
separately ?
If I create my own class MyClass
then I cannot do something like this MyClass anInstance = new MyClass();
MyClass need first to be imported. Why is this not mandatory for the PrintStream
?
Thanks in advance.