. * 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.

[446 byte] By [kevinchanga] at [2007-11-27 11:19:02]
# 1

AFAIK, importing is not recursive. If a package has subpackages and you need them, you have to import them separately.

petes1234a at 2007-7-29 14:34:27 > top of Java-index,Java Essentials,New To Java...
# 2

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 > top of Java-index,Java Essentials,New To Java...
# 3

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..(^_^);

QussayNajjara at 2007-7-29 14:34:27 > top of Java-index,Java Essentials,New To Java...
# 4

> 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

georgemca at 2007-7-29 14:34:27 > top of Java-index,Java Essentials,New To Java...
# 5

> 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 > top of Java-index,Java Essentials,New To Java...