• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Doubt on Package Example

 
Bala jee
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have the following example but not sure how to call the Parent class from the child class.

Lets assume the Parent Class is defined without any package as below,



Now we have a child class inside a package called myPackage.


The class child will not compile because Parent is not in same package as child so I need to import the Parent package but Parent is not in any package so how can I make this code to work?
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35279
384
Eclipse IDE Java VI Editor
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bala,
You need to put Parent in a package. Using the default package is discouraged. What you've encountered is one of the problems in that space - that you can't import something from the default package.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic