Since I’m still new to Java, I’m running into some need for clarification how imports should be done properly.
First:
import java.awt.*;
import java.swing.*;
I’m assuming the * means anything under the “awt” and “swing” directory.
But I’ve seen people doing this before:
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import java.awt.*;
import java.awt.event.*;
import java.net.URL;
import javax.swing.*;
Am I misunderstanding something? Or am I simply finding redundancy?
Will include all of the classes in the package
javax.awthowever it will not inclue any other packages nested inside ofjavax.awtsuch asjavax.awt.event. You need to use that as a separate import. All packages of different names needed to be included separately.Using
import javax.swing.*you will not need the following imports:because they are direct children of the
swingpackage.