Java Scanner is a special Java class that is used to take inputs from all kinds of inout streams. The system console, files, StringBuilder, StringBuffers are to name a few.
The following code snippet gets input from system console and reads it using Java Scanner utility class.
import java.util.Scanner;/*** An example program to read a String from console input in Java*/public class CSharpCorner{public static void main(String[] args){System.out.print("Enter a string : ");Scanner scanner = new Scanner(System.in);String inputString = scanner. nextLine();System.out.println("String read from console is : \n"+inputString);}}
‘System.in’ means console, so in the above code we are telling Java compiler to accept input from the console, and save the accepted input into a String variable named ‘inputString’
For a detailed tutorial on Java Scanner, visit
https://www.c-sharpcorner.com/article/java-scanner-tutorials/

