Win a copy of AWS Security this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

import in applets

 
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 ?
 
Saloon Keeper
Posts: 22146
151
Android Eclipse IDE Tomcat Server Redhat Java 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.
 
They worship nothing. They say it's because nothing lasts forever. Like this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic