This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
.* is used to specify that all classes should included in the package. But when you use package statement in a source file we will be putting the class defined in the source file in the the specified package. package org.*; is not a valid.
[ SCJP 6.0 - 90% ] , JSP, Servlets and Learning EJB.
Try out the programs using a TextEditor. Textpad - Java 6 api
Rajesh k Jha
Joined: May 10, 2009
Now i can conclude that we should try to avoid the use of * with packages(Even if one class is there in the package) but can use * with import statement freely.
You can use * in import statements, but often it is better to import classes explicitly one by one, instead of importing everything in a package with *. That's because using import with * can make your program not compile anymore with a future version of Java (or a future version of a third-party library you're importing).
If, in a future version, a class is added to a package that you're importing with "import somepackage.*;" and that new class happens to have the same name as another class that you're using in the same source file, then the compiler suddenly has two classes that have the same (non-qualified) name, and your program won't compile anymore.
When you import only the classes that you really need from 'somepackage', you won't automatically import new classes from 'somepackage' when a new version of that package is used and you won't have a name clash problem.