Python | Java |
A module is imported using the form import <module name>
The resources of that module are then referenced using the form <module name>.<resource name> Example: print(math.sqrt(2), math.pi) Alternatively, an individual resource can be imported using the form Examples: print(sqrt(2), pi) from random import * # Reference all resources from random |
A package resource is imported using the formimport <package name>.<resource name>;
The resource is then referenced without the package name as a qualifier. Example: import javax.swing.JButton; JButton b = new JButton(“Reset”); Alternatively, all of the package’s resources can be imported using the form import <package name>.*; Occasionally, two resources will have the same name in different packages. To use both resources, do not import them but just reference them using the package names as qualifiers. Example: java.awt.List namesView = new java.awt.List(); |