Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

packages -namespace

 
Daniel .J.Hyslop
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"packages prevent name collisions because each package creates a class namespace".:-taken from a training manual on java

I understand the concept of deviding the classes into seperate packages where one class can have the identical name to another class as long as it is sourced in a different directory.I wonder if someone could describe what is meant by creating a "class namespace".I realise this probably means a seperation of the classes into different packages but hopefully someone could just confirm this for me . thankyou in advance
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You got it. Packages have several uses. One is just to organize code so it's easier to manage than a zillion classes in one folder. For that purpose, packages are pretty much just namespaces. They mirror a directory structure on disk so you can have the same name in two packages just as you would in two folders.

Packages also play a role in design by managing visibility and scope of some classes. And you can think of a package as a unit of deployment, though that usually turns out to be a larger "component" than just a package.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic