title: Java Packages - Import vs Explicit Inclusion
body: <p>I thought I reasonably understood the use of packages but am experiencing an ostensibly trivial issue when attempting to use a method from an imported package. </p>
  
  <p>I have three files in the following directory structure:</p>
  
  <ul>
  <li>Tester.java</li>
  <li>approach1\Approach.java</li>
  <li>approach2\Approach.java</li>
  </ul>
  
  <p>Their code is as follows:</p>
  
  <p><strong>Tester.java</strong></p>
  
  <pre><code>import approach1.Approach;
  
  public class Tester {
  
      public static void main(String[] args)
      {
          approach1.Approach.sharedMethod("TEXT");
  
          sharedMethod("TEXT");
      }
  }
  </code></pre>
  
  <p><strong>approach1\Approach.java</strong></p>
  
  <pre><code>package approach1; 
  
  public class Approach {
  
      public static void sharedMethod(String approachText)
      {
          System.out.println("Approach Text: " + approachText);
      }
  }
  </code></pre>
  
  <p><strong>approach2\Approach.java</strong></p>
  
  <pre><code>package approach2;
  
  public class Approach {
  
      public static void sharedMethod(String approachText) { }
  
  }
  </code></pre>
  
  <p>As you can likely guess, I'm trying to elicit different responses from the different approaches based on what package/class is imported. The problem I encounter is within <strong>Tester.java</strong>. The first, explicit line works fine whereas the second, imported line (sharedMethod("TEXT")) throws an error of <em>"The method sharedMethod(String) is undefined for the type Tester"</em>. I don't understand as I have imported one of the packages, so the method should be visible.</p>
  
  <p>Any clarification would be appreicated as I'm a Java newb. Thanks!</p>