why cant create an object from same package different files?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • fazilhussain
    New Member
    • Jan 2008
    • 1

    why cant create an object from same package different files?

    i tried to create an object of a class created with a different file and it worked. But when i try to create the object after packaging it didnt compile. why is that? pls if u know the correct reason email me or post here (XXX@XXX)

    WORKED CODES......

    //A.java
    class A{

    A(){
    B b=new B();
    }// const end

    public static void main(String[] arg){
    new A();
    }// main end
    }// class end


    //B.java
    class B{
    }


    DIDNT WORKED......... ....

    //A.java
    package pac;
    class A{

    A(){
    B b=new B();
    }// const end

    public static void main(String[] arg){
    new A();
    }// main end
    }// class end


    //B.java
    package pac;
    class B{
    }
    Last edited by BigDaddyLH; Jan 16 '08, 05:14 PM. Reason: removed email address
  • dmjpro
    Top Contributor
    • Jan 2007
    • 2476

    #2
    Originally posted by fazilhussain
    i tried to create an object of a class created with a different file and it worked. But when i try to create the object after packaging it didnt compile. why is that? pls if u know the correct reason email me or post here (XXX@XXX)

    WORKED CODES......

    //A.java
    class A{

    A(){
    B b=new B();
    }// const end

    public static void main(String[] arg){
    new A();
    }// main end
    }// class end


    //B.java
    class B{
    }


    DIDNT WORKED......... ....

    //A.java
    package pac;
    class A{

    A(){
    B b=new B();
    }// const end

    public static void main(String[] arg){
    new A();
    }// main end
    }// class end


    //B.java
    package pac;
    class B{
    }
    First of all you looking for answer in mail. It is not valid here.
    Then you are not using Code Tag.
    Read out the posting guidelines carefully.
    Did you read about package?
    If your class is in different package then import this before accessing that class.

    Debasis Jana
    Last edited by BigDaddyLH; Jan 16 '08, 05:15 PM. Reason: removed email address

    Comment

    • ajos
      Contributor
      • Aug 2007
      • 283

      #3
      Originally posted by dmjpro
      First of all you looking for answer in mail. It is not valid here.
      Then you are not using Code Tag.
      Read out the posting guidelines carefully.
      Did you read about package?
      If your class is in different package then import this before accessing that class.

      Debasis Jana
      I dont think he mentioned different package. :).
      BTW it would be intresting to know what errors you are getting .
      regards,
      ajos

      Comment

      • BigDaddyLH
        Recognized Expert Top Contributor
        • Dec 2007
        • 1216

        #4
        Originally posted by fazilhussain
        pls if u know the correct reason email me or post here (XXX@XXX)
        Email replies are discouraged because it doesn't help other forum members with the same problem who find this thread.

        Comment

        Working...