Style question: When to import using wildcards (somepackage.*)?
I have a style question: When is it appropriate to use the wildcard asterix when importing packages and libraries?
My gut instinct is that one should generally import each class as needed, but that using the wildcard is a quick shortcut used when there are going to be too many import statements. But am I right in thinking that there's a price to pay in terms of either speed or just the size of the final program if wildcards are used?
For example, my gui (created by Netbean's gui-builder) has the import statements
import java.awt.Component;
import java.awt.Dimension;
import java.awt.DisplayMode;
import java.awt.GraphicsDevice;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.GraphicsEnvironment;
import java.awt.Rectangle;
import java.awt.Color;
import java.awt.Toolkit;
import java.awt.Point;
import java.awt.Cursor;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.ImageIcon;
import java.net.URL;
import java.io.File;
My guess is that most programers, if they were writing the gui by hand, would have used
import java.awt.*
am I right? But is the former better and the latter a bad habit?
Also, I assume that, if I know I'm going to want the entire package, I should use the wildcard? For instance, in one of my programs, I have a set of data types in a package called 'datatype'. As I use them all in one of my classes, I use 'Import datatype.*'. Is there any performance benefit either way in this case?
Thanks!
--Sam

