. * problem
Hi all,
I am a little bit confused about how to import package correctly. Typically, ".*" means all ,right ? However, some of the cases I read in java books actually import detail class(es) ot the same package when this package is imported at the same time. For example,
import java.awt.*
import java.awt.event.*
Please help me out. Thanks.
importing java.awt.* does NOT import anything in java.awt.event. It only imports classes at the java.awt level. Packages are NOT hierarchical.
In addition, if you do, say, this:
import java.util.*;
import java.sql.*;
then you'll have to explicitly import java.util.Date or java.sql.Date if you want to use one of them without specifying the full package name.
jverda at 2007-7-29 14:34:27 >

and always be sure that importing all classes doesn't slow down the progress of your program, because importing full packages is just getting a reference to those classes, not loading the classes to your program..(^_^);
> and always be sure that importing all classes doesn't
> slow down the progress of your program, because
> importing full packages is just getting a reference
> to those classes, not loading the classes to your
> program..(^_^);
Importing has absolutely no effect whatsoever at runtime. It's just a way for you to avoid typing out fully.qualified.Names of classes in your source code
> and always be sure that importing all classes doesn't
> slow down the progress of your program,
It never will. Importing has ZERO runtime effect. All it does is tell the compiler that, for examle, "List" means "java.util.List."
> because
> importing full packages is just getting a reference
> to those classes, not loading the classes to your
> program..(^_^);
Importing has nothing to do with loading classes. It has no efect at runtime.
jverda at 2007-7-29 14:34:27 >
