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.
It will import only classes in java.awt, so you have to import java.awt.event too:
import java.awt.*
import java.awt.event.*;
Second method will probably load less classes, but won't save you much memory.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With