title: Why can I leave out an import statement when chaining methods, but not if I call them individually?
body: <p>For example, in this simple Java program:</p>
  
  <ol>
  <li>If I write:</li>
  </ol>
  
  <p><code>frame.getContentPane().add(button);</code></p>
  
  <p>I only need to <code>import javax.swing.*;</code> and the code compiles perfectly.</p>
  
  <ol start="2">
  <li>However, if I write:</li>
  </ol>
  
  <p><code>Container cont = frame.getContentPane();
  cont.add(button);</code></p>
  
  <p>I have to both <code>import javax.swing.*;</code> and <code>import java.awt.*;</code> for there not to be a <code>cannot find symbol</code> compiler error.</p>
  
  <p>Aren't both ways of writing it technically exactly the same? Why need less or more import statements one way or the other?</p>
  
  <p>When I'm calling it in the first way as seen in my example, doesn't getContentPane() still return a Container type object even though I might not be referring to it with a Container reference variable?</p>