Importing a package is a way to introduce a library or class in Java: Explicit import: Use import to import the fully qualified name of a class or package. Implicit import: Automatically import some common packages, such as java.lang.
Guiding a package is a basic operation in Java
In a Java program, guiding a package refers to introducing a specific libraries or classes to use them in your own code. By importing a package, you can access external classes or methods without having to manually write their detailed paths.
There are two ways to import a package:
import
keyword followed by the class or package to be imported Fully qualified name, for example: <code class="java">import java.util.Scanner;</code>
This will import the java.util.Scanner
class, allowing the Scanner
object to be used in your program.
java.lang
, which contain basic types (such as int
and String
) and common methods (such as Math.sqrt()
). The benefits of imported packages include:
The above is the detailed content of What does import package mean in java. For more information, please follow other related articles on the PHP Chinese website!