• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

is subpackage considered as same package?

 
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
consider the following code:





so here we have a subclass access a superclass instance, which are both in the "root" package world,
if i get rid of public at line 1, the compiler complaints.
is it because of subpackage is not considered as same package, or something else is wrong in the code?


just one more thing,
if i use
import world.moon;
in the world class,
why does it not work?
[ November 05, 2007: Message edited by: adam lui ]
 
Ranch Hand
Posts: 513
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Adam,

There's no such thing as a subpackage in Java. For all intents and purposes, "world" and "world.moon" are completely different packages. This is a bit non-intuitive because the .class files are stored hierarchically in the file system... but they don't in fact share a "subpackage" relationship in Java.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic