I am currently working on a tutorial that uses the following imports:
//importing Resources
import java.awt.*;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import javax.swing.*;
My question is: does java.awt.* import everything from awt? And if so why is this necessary?
import java.awt.event.ItemEvent;
My question is: does java.awt.* import everything from awt?
It imports all the classes in java.awt
, but that's all.
And if so why is this necessary?
import java.awt.event.ItemEvent;
Because that's not in java.awt
- it's in java.awt.event
. Packages in Java aren't really hierarchical, even though they look that way. As far as the Java language is concerned, java.awt
and java.awt.event
are entirely separate packages.
See more on this question at Stackoverflow