User Input in JAVA (I/0 Interaction Process)

  Here, the user input is used in the learning of the array, that is, the interactive mode. The daily data cannot be defined by the programmer every time. After all, interaction between the user and the program is required. The machine waits for user input, and the user passes the keyboard. Enter the required data (data includes, characters, strings, values, etc.).

 

  There are many ways to enter data, here is the simplest one. Input through the Scanner class. First of all, Scanner is a built-in class in JAVA, which needs to be instantiated by importing the package.

 

  First import the package:

   1 import java.util.Scanner; 

 

  Then instantiate the class:

   1 Scanner sc = new Scanner(System.in); // Create an input stream object 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324829450&siteId=291194637