Results 1 to 7 of 7
  1. #1
    tomcat383 is offline Member
    Join Date
    Nov 2009
    Posts
    4
    Rep Power
    0

    Angry Bginners issue i think rgarding Import

    HI ,

    I want to use a different classes with the same name in a different packages.
    Example :
    first package name is aaa.bbb.ccc.ddd and the class name is eee.
    second package name is aaa.ccc.ddd and the class name is eee.
    it looks like that:

    import aaa.bbb.ccc.ddd.eee
    import aaa.ccc.ddd.eee

    sometimes i want to use the first class and sometimes i want to use the second one. is it possible ???? :confused::(:confused:
    i am getting crazy....
    Note :I cannot change the package*or class names.

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

  3. #3
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,302
    Blog Entries
    7
    Rep Power
    20

    Default

    You have to use the fully qualified name for those classes, i.e. you can't import both classes but have to use the package.package.YourClass notation.

    kind regards,

    Jos

  4. #4
    tomcat383 is offline Member
    Join Date
    Nov 2009
    Posts
    4
    Rep Power
    0

    Default

    Thanks for the answer.

    did you mean some like that :
    first class use:
    aaa.bbb.ccc.ddd.eee test1 = new aaa.bbb.ccc.ddd.eee();
    second class use:
    aaa.ccc.ddd.eee test2= new aaa.bbb.ccc.eee();

    is it correct ?

  5. #5
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,302
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by tomcat383 View Post
    Thanks for the answer.

    did you mean some like that :
    first class use:
    aaa.bbb.ccc.ddd.eee test1 = new aaa.bbb.ccc.ddd.eee();
    second class use:
    aaa.ccc.ddd.eee test2= new aaa.bbb.ccc.eee();

    is it correct ?
    Yep that is correct; if you want you can use an import statement for one of the classes but not for both; it's a bit mechanical but otherwise the compiler has no way of distinguishing one class from the other.

    kind regards,

    Jos

  6. #6
    tomcat383 is offline Member
    Join Date
    Nov 2009
    Posts
    4
    Rep Power
    0

    Default

    Thanks guys i will try it tommorow and let you know if it fixed my problem ...
    Thanks allot :-)..

  7. #7
    tomcat383 is offline Member
    Join Date
    Nov 2009
    Posts
    4
    Rep Power
    0

Similar Threads

  1. Eclipse 3.5<import *.jar -Need help>
    By roughjj in forum Eclipse
    Replies: 1
    Last Post: 09-09-2009, 09:24 AM
  2. Import / Export Issue
    By Gideonzx in forum Eclipse
    Replies: 0
    Last Post: 07-23-2009, 08:08 PM
  3. How could i import DLL in NetBeans?
    By makpandian in forum NetBeans
    Replies: 0
    Last Post: 02-13-2009, 12:53 PM
  4. can any one help?? how to import library
    By libish in forum New To Java
    Replies: 5
    Last Post: 02-12-2009, 06:51 AM
  5. import statement.
    By diRisig in forum New To Java
    Replies: 2
    Last Post: 02-08-2008, 12:34 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •