Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Import statements

 
chris czinder
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
thanks,
Chris
 
Joe Pluta
Ranch Hand
Posts: 1376
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
Joe
 
chris czinder
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic