Search⌘ K
AI Features

Ask the User

Explore how to use the Scanner class in Java to capture user input. Learn to import Scanner, read lines of text, and obtain numerical input. This lesson shows you how to build simple interactive programs that respond to user entries.

So far, you’ve printed and stored text. Now it’s time to get input from the user. In this lesson, you’ll use Scanner to read what someone types.

Goal

You’ll aim to:

    ...