- Language Fundamentals
- Introduction
- The Structure of Java Programs
- Identifying Packages
- Importing Classes and Interfaces from Other Packages
- The main() Method
- Comments
- Identifiers and Keywords
- Primitive Types and Literal Values
- Chapter Summary
Importing Classes and Interfaces from Other Packages
The import statement is used to reference classes and interfaces that are declared in other packages (without having to specify their names each time they are referenced). The import statement comes in three forms:
Importing java.lang
The java.lang package is always imported by default and does not need to be imported by an import statement.
The first and second forms enable the identified classes and interfaces to be referenced without specifying the name of their package. The third form allows all classes and interfaces in the specified package to be referenced without specifying the name of their package.
Method Modifiers
The static modifier identifies that a method applies to a class as a whole and not to a specific instance of a class (that is, an object). The public modifier identifies that a method can be accessed anywhere that its class can be accessed. Modifiers are covered in detail in Chapter 4, "Declarations and Access Control."