Java Console Input
Access the Scanner code
- Put this in the top area of the code between the package name class name
- No need to understand this yet, it will be easier to understand it after you learn what a 'class' is
Receive user input from the console:
- The code following the input commend will not be run until the user types into the console and presses the Enter key
- Usually you should display a prompt (with System.out.println) before receiving user input, so that the user knows what to do
- In this example, the variable 'myTypedContent' will store the value that the user types in
Receive a specific type of input:
- This also works for nextBoolean, nextFloat, nextDouble, nextLong, etc.
Challenge
Prompt the user for a number, display that number multiplied by 5;