Author | Topic: import statements |
Rekha Suri greenhorn |
posted April 07, 2000 02:57 PM
Hi, When you have the following code import java.awt.*; Is it necessary to have the second import statement ? The first import statement will anyway import all the classes and members of the awt package, then why are we explicitly importing the java.awt.event class?
|
Shiva ranch hand |
posted April 07, 2000 03:11 PM
IMO when you just need event class then you should use the second one, i guess to reduce the load of JVM by not importing all the classes of awt pl corect me if i am wrong
|
NewJava2User unregistered |
posted April 07, 2000 03:18 PM
They are both 2 different packages. java.awt.event package Provides interfaces and classes for dealing with different types of events fired by AWT components. java.awt package Contains all of the classes for creating user interfaces and for painting graphics and images. Hope this helps!
|
maha anna bartender |
posted April 07, 2000 03:31 PM
Rekha, As NewJava2User said, java.awt and java.awt.event are 2 seperate packages. Here the event package happened to be kept inside the java.awt package. It is like a sub-package. Generally in Java, all related classe of some kind are kept under a single package. Here the event related classes and interfaces are seperated from the other awt GUI related classes and interfaces. One more point to know is import java.awt.*; does not import all classes and interfaces under the sub-package event . You have to explicitly import java.awt.event.*; regds maha anna [This message has been edited by maha anna (edited April 07, 2000).]
|
Rekha Suri greenhorn |
posted April 08, 2000 07:55 PM
Thanks a lot Shiva, NewJava2User and Maha Anna. You all cleared a basic concept that I had taken for granted.
|
| | |