Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

simple qs on import  RSS feed

 
Susmita Pal
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When we import a java.awt.*; all the class files and sub files of the packages are supposed to be imported.
Then why do we need to import java.awt.event.*; specifically for event handling.
Thanks in advance
Susmita
 
Wilfried LAURENT
Ranch Hand
Posts: 269
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Susmita Pal:
When we import a java.awt.*; all the class files and sub files of the packages are supposed to be imported.

The JSR states in the package paragraph that
"A type-import-on-demand declaration (such as import java.lang. *) allows all public types declared in the package named by a fully qualified name to be imported as needed. "
There is no mention about subpackages. Anyway, imagine that you do not need to explicitely import subpackages but only the "father" package.
You would only have to put a "import java.*" at the top of your program to import, when needed, all the java classes! It would make your code unreadable.
W.


[This message has been edited by Wilfried LAURENT (edited October 15, 2001).]
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!