Learn Java Tutorial for Beginners (Video), Part 7: Getting User Input

How to get console user input in your Java programs using the JDK Scanner class.

When the video is running, click the maximize button in the lower-right-hand corner to make it full screen.

Code for this tutorial:

import java.util.Scanner;

public class App {
    public static void main(String[] args) {
        // Create scanner object
        Scanner input = new Scanner(System.in);
        // Output the prompt
        System.out.println("Enter a floating point value: ");
        // Wait for the user to enter something.
        double value = input.nextDouble();
        // Tell them what they entered.
        System.out.println("You entered: " + value);


Note: if you're in Europe outside the UK, you might need to enter floating point numbers in the format x,y rather than x.y as is normal in the USA and UK.

Enter a floating point value: 
You entered: 5.6