Home > Articles

Language Fundamentals

  • Print
  • + Share This
This chapter is from the book

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:

import packageName.className;
import packageName.interfaceName;
import packageName.*;

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."

  • + Share This
  • 🔖 Save To Your Account