File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Import statements Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Import statements" Watch "Import statements" New topic

Import statements

chris czinder

Joined: Oct 02, 2002
Posts: 28
Now I understand that import statements are important and what not, but my question is why if I have already done this

I need this

to make the following program work

It seems odd, that if I've already included java.awt.* that it would include java.awt.event.*
Just wondering
Joe Pluta
Ranch Hand

Joined: Jun 23, 2003
Posts: 1376
I thought the same thing, Chris, but as it turns out, imports are not recursive. That is, they do not automatically include "subpackages". In fact, there is no such thing as a subpackage. The name java.awt.event has nothing to do with java.awt. For each package you wish to specify, yuou must specify the complete package name.
It's kind of like specifying a path in DOS, or a classpath in Java. If you specify /myfolder/mystuff, it will not automatically look in /myfolder/mystuff/myotherstuff.
chris czinder

Joined: Oct 02, 2002
Posts: 28
Thanks a lot, that clears it up. I had just naturally figured that it would/should be recursive.
Should know better then to just assume anything in the computer world is as it should be
I agree. Here's the link:
subject: Import statements
It's not a secret anymore!