class TestFormat { public static void main(String[] args) { System.out.println("hello"); } }
In the simple code above, the out
object is of type java.io.PrintStream
. The println()
method also belongs to the PrintStream
class. PrintStream
is in another package, then java.lang
, which is the standard java package.
My question is: how can we use a class method from a package ( java.io
) that we did not even import? It is provided that an object of this class has already been provided to us, but does this mean that we need to import the package only to create an object of the class from this package and not use its methods later?
Thnax in advance!
source share