Input ********/for/********* data
/** using scanner scanner for data entry
How to use the scanner scanner
Before the class declaration, introduce the scanner
Import Java.util.Scanner;
Declare a new scanner (that is, request a space for memory)
Scanner in
Value Assignment
In=new Scanner (system.in);
Scanner in=new Scanner (system.in);
Use the scanner.
Shaping data input: In.nextint () to receive
Double decimal Input: In.nextdouble () to receive
String input: In.next () to receive
There is no way to accept the input of a single string
**/
Import java.util.*;
You can also use the sub-package import Java.util.Scanner;
Class eqw{
public static void Main (String args[])
{
Scanner in=new Scanner (system.in);
SYSTEM.OUT.PRINTLN ("Pls input name:");
String Name=in.next ();
SYSTEM.OUT.PRINTLN ("Pls input nianji:");
int Nianji=in.nextint ();
System.out.println ("Name:" +name);
System.out.println ("Nianji:" +nianji);
}
}
Java Learning notes [using scanner scanner for data entry]