Possible Duplicate:
Import package.* vs import package.SpecificType
Can I do:
import java.awt.*
instead of:
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
if both ways are correct which one is better?
You can import the general package, but it’s better to be more explicit and import the specific classes you need. It helps to prevent namespace collision issues and is much nicer.
Also, if you’re using Eclipse and the shortcut CTRL+SHIFT+O it will automatically generate the explicit imports, prompting you for the ambiguous imports.