This week's giveaway is in the EJB and other Java EE Technologies forum. We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line! See this thread for details.
If no package name is specified in a class or interface then that class or interface is said to be part of the "default" or "unnamed" package. Note that if you place your class or interface in the default package then all other classes or interfaces in all other packages will have access to that class (unless it is declared private). For this reason it is considered good practice to put all classes and interfaces in packages.
Unfortunately, that doesn't work me. For example, I'll have those unnamed classes in a jar and put them in my classpath and reference them in another unnamed class. Works. As soon as I put a package statement on MY unnamed class, it says it can't find the (unnamed) classes in the jar file. Am I missing something? I assume from that quote I can reference the class as if it were part of the same package in the class, ie. no imports of the class are needed.
I guess unnamed-package classes can not use named-package classes. Or the other way around perhaps - classes in named packages cannot use classes in the unnamed package, while classes in the unnamed package can use classes in named classes, provided the CLASSPATH is set correctly and the correct import statements are used.