Do we need to import a package only to create an object or to call a method from that object as well?
<pre><code>class TestFormat
{
    public static void main(String[] args)
    {
        System.out.println("hello");
    }
}
</code></pre>

<p>In the above simple code the <code>out</code> object is of type <code>java.io.PrintStream</code>. The <code>println()</code> method is also of class <code>PrintStream</code>. <code>PrintStream</code> resides in a different package then <code>java.lang</code> which is the default java package.</p>

<p>My question is how are we able to use method of a class from a package(<code>java.io</code>) we have not even imported? Granted that the object of that class is already provided to us but does that means that we need to import a package only to create an object of a class from that package and not to use its methods afterwards?</p>

<p>Thnax in advance!</p>
