Flash cards
Review the key moves
1/4
Core idea
What is the main idea behind Java import Keyword?
Lesson checks
Practice each idea before moving on
Short Mimo-style checks built from this lesson's code, terms, and sequence.
1Quick choice
Which statement best captures the main point of this lesson?
2Fill blank
Complete the missing token from the example code.
___ java.util.Scanner;3Order
Put the learning moves in the order that makes the concept easiest to apply.
Import the Scanner class from the Java API:
Definition and Usage
Java import Keyword
❮ Java Keywords
Example
Import the Scanner class from the Java API:
import java.util.Scanner;
class MyClass {
public static void main(String[] args) {
Scanner myObj = new Scanner(System.in);
System.out.println("Enter username");
String userName = myObj.nextLine();
System.out.println("Username is: " + userName);
}
}Definition and Usage
The import keyword is used to import a package, class or interface.
Related Pages
Read more about packages in our Java Packages Tutorial .
❮ Java Keywords