Java learning to receive input characters from the console
Tools: NetBeans
The system class has an implementation of the in input stream in addition to the out and err two output streams.
To create a class casually, I am using the Helloword class to create a scanner scan in the main method of the class to encapsulate the input stream of the system class, and then prompt the user to enter the ID number and output the number of digits of the user's identity card number.
1 PackageHelloword;2 ImportJava.util.Scanner;3 /**4 *5 * @authorAdministrator6 */7 Public classHelloword {8 /**9 * @paramargs the command line argumentsTen */ One Public Static voidMain (string[] args) { A //TODO Code application logic here -Scanner scanner=NewScanner (system.in); -System.out.println ("Please enter your identity card number:"); theString line=scanner.nextline (); -System.out.println ("The original is your ID number is" +line.length () + "bit of the number of AH"); - } - +}
Summary: At first unsuccessful, the hint Scanner error, study a bit found without add import java.util.Scanner Novice to pay attention to AH
Java learning to receive input characters from the console