A great strength of Java is its rich set of predefined classes that you can reuse rather than “reinventing the wheel.” These classes are grouped into packages—named groups of related classes—and are collectively referred to as the Java class library, or the Java Application Programming Interface (Java API). Line 3
import java.util.Scanner; // program uses class Scanner
is an import declaration that helps the compiler locate a class that’s used in this program. It indicates that the program uses the predefined
Scanner class (discussed shortly) from the package named java.util. The compiler then ensures that you use the class correctly.
Common Programming Error 2.7
All import declarations ...