CIS 260 Notes: Namespaces
Objectives
- Discuss namespace, import, and full path specification issues
Namespaces
- Java has many libraries with many available classes that can be used for
common tasks. It would be a real nuisance if all of the names used in the
Java libraries were all immediately visible and reserved. The import statement
allows us to only access those libraries/namespaces that we wish to use.
- import java.awt.Graphics; // lets the compiler use the Graphics class from the awt package
- import java.awt.*; // lets the compiler use all of the classes in the awt package
- import java.awt.event.*; // Note: These classes are not included by: import java.awt.*;
- You don't actually have to use any import statements if you are willing to fully qualify the name
of your classes: javax.swing.JOptionPane.showInputDialog("Enter your name");