Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

import in applets

 
hennie louw
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was wondering, one can use the syntax " import java.awt.*; " and also "import java.awt.Image; " if you want to use the image class but isn't the latter better, if so why ?
 
Tim Holloway
Saloon Keeper
Posts: 18366
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The "wildcard" import is effectively the same as coding an explicit import for every package at that level of that path of the class tree. It's an easy way to get everything you need without having to keep going back and coding another import, but there are 2 consequences.
1) You cause a lot of unused definitions to get dumped into the mix, which takes extra time and other overhead.
2) You open up more possibilities for naming ambiguities (suppose Sun suddenly released a java with class java.awt.String!)
In some cases, such as java.awt and javax.swing, you'll end up with the full load eventually, so it doesn't much matter. For others - such as java.util, I usually like to be more selective.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic