User Program Communication

Import Package in Java

Used to import a package with pre-defined features.

import packageName; //import entire package
import packageName.member; //import member from package


The JDK includes many packages for use, but custom packages can also be imported using the IDE.

When only a few methods are used, it is best to import these methods individually. It is bad practice to import an entire package if only a few methods from the package are used.

import java.util.Scanner;

//somewhere else in the code
Scanner textScanner = new Scanner();

< Write to File   |   Primitive Data Types >

© 2019 SyntaxDB. All Rights Reserved.