title: parent package class accessible from child packge class in java?
body: <p>In java parent package class accessible from child packge class? please explain me any one?</p>
  
  <p>example
  package A.A1.A2 contains class sub
  package A contains class sup</p>
  
  <p>Is there anyway to access sup from sub?</p>
  
  <p>pls explain.</p>
  
  <p>i tried import it won't work
  Example:
  before the program Directory Structure is 
  package1 contains package1.java --> package2 --> package3 contains PCheck.java</p>
  
  <pre><code>//package1.java
  package package1;
  public class package1{
      public static void main(String[] args) {
  
      }
  }
  class phelo{
      phelo(){
          int a;
          System.out.println("hai fun freom package 1");
      }
  }
  
  //PCheck.java;
  package package1.package2.package3;
  import package1.*;   //to import package1.java
  public class PCheck {
      public static void main(String[] args) {
          phelo obj=new phelo();
      }
  }
  class helo{
      helo(){
          int a;
          System.out.println("hai fun from package 3");
      }
  }
  </code></pre>
  
  <p>output:
  compile time error:package package1.package2.package3 doesnot exist;</p>
  
  <p>for import class from different directory we use import statements but here we need access parent package from subpackage.i tried import  it won't work  pls explain with an example.</p>