Let's understand it with the help of a simple code example
import java.util.Scanner;
public class UserInputExample {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Enter a number: ");
int number = scanner.nextInt();
System.out.println("You entered: " + number);
scanner.close();
}
}
Well, in the above code example, it takes a number as input from the user and will display that number as output.
Thanks