• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Named Vs Unnamed Packages

 
Ranch Hand
Posts: 238
1
Eclipse IDE Fedora Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
I have a little doubt regarding two codes:

file Bclasse.java
package BBB;
class Bclasse extends Aclasse
{
public static void main(String...a)
{
}
}

File Aclasse.java
public class Aclasse
{
public static void main(String...a)
{
System.out.println("printed in class A");
}
}


Now as you can see that the two codes are in separate files,why is Bclasse unable to access Aclasse even if Aclasse is coderanch.Is it because Aclasse is in unnamed package and Bclasse is in a named package?How does that makes a difference?


Thanks....
 
Rancher
Posts: 1776
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Though the class is coderanch, since it's in different package, you have to import it. But for importing the class, you have to specify the fully qualified class name with the package name. So you have no chance of importing classes in default package and using it in a class that belongs to a named package.
reply
    Bookmark Topic Watch Topic
  • New Topic