Advertisement
earlution

Java user input

May 10th, 2020
917
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.45 KB | None | 0 0
  1. import java.util.Scanner;  // Import the Scanner class
  2.  
  3. class MyClass {
  4.   public static void main(String[] args) {
  5.     Scanner scan = new Scanner(System.in);  // Create a Scanner object
  6.     System.out.println("Please enter the value you want to store:");  // Output text to the terminal
  7.     String userInput = scan.nextLine();  // Read user input and store in a variable
  8.     System.out.println("Your value is: " + userInput);  // Output user input
  9.   }
  10. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement