File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes packages -namespace Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "packages -namespace" Watch "packages -namespace" New topic

packages -namespace

Daniel .J.Hyslop
Ranch Hand

Joined: May 23, 2005
Posts: 55
"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

an island in the sun <br />with a language of many tongue?
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
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.

A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
I agree. Here's the link:
subject: packages -namespace
It's not a secret anymore!